Track My Order
Frequently Asked Questions
International Shipping Info
Mon-Fri, 9am to 12pm and
1pm to 5pm U.S. Mountain Time:
Chat With Us
July 9, 2009
about 2 years ago
Thank you. But 2 lines further down he “gets rid of the decimal portion”. If a sign conversion of the decimal part is necessary, of course he will not bother to do it, but I want to keep the decimal part and am still unsure if I need to do a sign conversion or not.
But okay, looking again,
float tempcsb = (lsb>>4)/16.0;
float altitude = (float)( (msb << 8) | csb) + tempcsb;
tells me not to sign convert the altitude decimals, but just scale them and add them to the signed integral part.
From the datasheet:
The Altitude data is arranged as 20-bit 2’s complement value in meters. The data is stored as meters with the 16 bits of OUT_P_MSB and OUT_P_CSB and with fractions of a meter stored in bits 7-4 of OUT_P_LSB. Be aware that the fractional bits are not signed, therefore, they are not represented in 2’s complement.
Does somebody know how this is to be understood?
Should I take the fractional part (LSB/256 units) and add it to the signed integral part?
Or should I take the fractional part (LSB/256 units), multiply it by the sign of the integral part, then add the two?
I don’t have the part here so I cannot just try..
No public wish lists :(
Forgot your password?
No account? Register one!