Currently I'm in the process of replacing a custom compass / accelerometer with an ST LSM303D. The 'old' custom device produced single precision floats. Without parsing the values there where just passed inside a UDP packet.
Unfortunately the LSM303D produces 16 bit signed integers. So, the embedded system needs to convert these values to floats. The scaling it self is quite simple: Values -32768..32767 need to be scaled to [-2,2).
Now, my hardware has no floating point support. However doing the following:
float output = ( (float)input ) / 16384f;
will require quite a bit of FP magic. I would imagine that this:
const float scale = 1f / 16384f; float output = ( (float)input ) * scale;
may be faster, but still requires FP multiply support.
Is there a simple and fast way which I can use to convert these integers to floats without the aid of an FP library? I have not found much code in this respect.
Vincent