如何计算任意数量的highByte
和lowByte
;
示例:
let mValue = 26513
mValue
= 0x6791
的十六进制表示形式
那如何找到上述数字的高低字节呢?
答案 0 :(得分:0)
已迅速更新:
以下解决方案对我有用:
let mVal = 26513 // hex value of mVal = 0x6791 (UInt16)
let highByte = (mVal >> 8) & 0xff // hex value of highByte = 0x0067 (UInt8)
let lowByte = mVal & 0xff // hex value of lowByte = 0x0091 (UInt8)
print("highByte: \(highByte)\nLowByte: \(lowByte)")