Re:ftoa
Magnus,
Thanks for sharing this. It's a very good piece! I tried it on my PC, it works as described. Even though I haven't tried it on an actual MCU, but I think it will work.
Here is my one cent comment:) 1. It would be nice to add control allowing user to select how many digits to output. This can be done by adding the third parameter. 2. Though this is minor, if float f has a large integral part and exceeds 7 digits, the displayed result is not correct. I modified the for loop condition to for (ix = 1; ix < 8 || dp >= 0; ix++) to fix it. Of course, the size of buf must be big enough. 3. If other users need more precision, replacing float with double can help. However, bigger code size and slower execution may result.
cheers, jc
login or register to reply
|