int i, f; float fnum = 0x41bba752; // this should be 23.4567 i = float32_to int32(fnum); lprintf("%d",i); lprintf("."); f = float32_to_int32(float32_mul(float32_sub(fnum,float32_from_int32(i)),10000)); lprintf("%d".f);
I am attempting to recombine a set of 4 bytes sent via I2c into a floating point number. I can see the 4 bytes being transferred using a logic analyzer and they are correct for the number I am transferring, but I can't get the recombined number to diaply correctly, so I tried to just load the floating point number as a hex value and I get garbage on the LCD.
Here's what I'm doing: see above (I guess - this thing never puts my code where I want it).
Anyway, the LCD shows -23040.-1 which is obviously wrong. So, why am I gettign such garbage? Any ideas?
If I use fnum = 23.4567, the LCD shows 23.4567. Maybe I did the conversion wrong, but Im pretty sure that 23.4567 = 0x41bba752.