I am having trouble using Microchips floating point routines, and I believe I'm just missing or misreading something simple. I don't actually want to do any math, but I am taking a float from a serial stream and want to display the value with 1 decimal point. I am hard coding an easy float into aint. I have used multiple online converters to verify that 50.0 = 0x42480000. I chose it because it is nice and round and does not use the parity bit for any of the bytes when I get to the point of going back to a serial line. I can't seem to get either ftoia or itofb to do what I thought they should do.
For inta the hex value before is displayed correctly, $42480000, however the value after conversion is the exact sameCode:include "fp1832l.bas" aint = $42480000 serout2 portc.6,newbaud,["a hex value = ", hex8 aint] gosub ftoia serout2 portc.6,newbaud,["after conversion, a hex value = ", hex8 aint] bint = 10 serout2 portc.6,newbaud,["b hex value = ", hex8 bint] gosub itofb 'convert to float serout2 portc.6,newbaud,["after conversion, b hex value = ", hex8 bint]
For intb, the hex value is as expected, $0000000A, but after the conversion it is $20000000. the online calculators show $41200000 is what a 10 should look like as a float.
If there is an easier way to get what I need, I would appreciate it or just helping me see what I'm missing. Again, I don't necessarily need math. I just want to convert a single float into a couple of variables for each side of the decimal to display.
Thanks for the clarification
David




Bookmarks