Shifting numbers in MMBasic


Author Message
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 12:51am 11 Mar 2012      

I had a look at the datasheet for the BMP085 and while it indicated which constants are signed it did not say the method. I suspect Bosch are relying on people using their code examples to do the job. Andy, you may have bitten off a large piece to chew on.

Assuming twos complement:

read your pair of bytes, combine them into a 16 bit number as shown above, check if the number is equal or greater than 0x8000 (means it is negative), if not then treat it as positive else invert it (number XOR &HFFFF) and add 1 and then change the sign to negative.