Merge two bytes in java/android

Posted by Shane on Stack Overflow See other posts from Stack Overflow or by Shane
Published on 2010-05-24T10:07:00Z Indexed on 2010/05/24 10:11 UTC
Read the original article Hit count: 283

Filed under:
|
|

Hi, I have a frame of 22 bytes. The frame is the input stream from an accelerometer via bluetooth. The acceleromter readings are a 16 bit number split over two bytes.

When i try to merge the bytes with buffer[1] + buffer[2], rather than adding the bytes, it just puts the results side by side. so 1+2 = 12.

Could someone tell me how to combine these two bytes to obtain the original number. (btw the bytes are sent little endian)

Thanks

© Stack Overflow or respective owner

Related posts about android

Related posts about byte