如何计算任意数字的highByte
和lowByte
;
示例:
let mValue = 26513
mValue
的十六进制表示形式 = 0x6791
那么如何找到上面数字的高字节和低字节呢?
最佳答案
Updated for swift :
以下解决方案对我有用:
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)")
关于ios - 在swift iOS中计算高字节和低字节?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57035368/