Reputation: 3327
How to calculate the highByte
and lowByte
of any number;
Example :
let mValue = 26513
hex representation of mValue
= 0x6791
Then how find high and low byte of above number?
Upvotes: 0
Views: 739
Reputation: 3327
Updated for swift :
below solution works for me:
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)")
Upvotes: 1