Now, i have googled this some, with not much as far as results, so I though I would ask here to see what kind of luck I would have.
I am using the Analog Devices ADuC831 (8052 ISA) part to do data acquisition and transmission. I have some data that is being held as floating point (single precision IEEE 754 format). Some of this data needs to be outputted to serial on request. This is where my request comes in. Currently I am using sprintf() to format this output into my buffer. HOWEVER, the footprint of this code is making it less than desirable to use (over 1100 bytes of code space and nearly 30 bytes of memory). So I am looking to do the output on my own.
And to this means, I have succeeded, to an extent. So far I have removed my need for sprintf() in printing HEX format, as well as ints and chars. My problem is with floats. I have not yet attempted standard notation: 3.1415926 But I did write an exponent formula. 3.141593E+00 I even got the rounding. HOWEVER, this is using simple multiplies and divides, by 10, to achieve it's goals. And this introduces my problem. Since a few of the numbers go out to 6 digits of precision, I am having problems with these last digits outputting correctly. For example:
Value entered: 6.791775E-08 Value displayed: 6.791777E-08 Hex value on chip: 0x3391DA2E (6.7917753e-8)
Clearly, the entered value is being stored correctly and the displayed value, while close, is just slightly off. So is there a way to do this without this error induced by my multiplications by 10 (and still not using sprintf()?
RonB
-------------------------------------------------- "It is human nature to take shortcuts in thinking"
--------------------------------------------------