I have some binary data (twos complement) coming from an accelerometer and I need to convert it to an integer. Is there a standard library function which does this, or do I need to write my own code?
For example: I receive an NSData object from the acclerometer, which when converted to hex looks like this:
C0088001803F
Which is a concatenation of 3 blocks of 2-byte data:
x = C008
y = 8001
z = 803F
Focussing on the x-axis only:
hex = C008
decimal = 49160
binary = 1100000000001000
twos complement = -16376
Is there a standard function for converting from C008 in twos complement directly to -16376?
Thank you.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…