How to count how many decimal places in a real or floating point number?

Started by etow, March 01, 2008, 12:14:26 AM

Previous topic - Next topic

etow

Hi

I was wondering if you have a floating point number result in 1.2345678 after numerical calculation
and you use FpuFLtoA function to convert a floating point number into a string to display it but you are not sure how many decimal places it will display.  How would you tell the number of floating point decimal places in the result floating point number after calculation?

Please help.

Thanks

u

See the format of FP data: http://en.wikipedia.org/wiki/Ieee_floating_point
So, determining the decimal places will require the same code/approach, used in FpuFLtoA. If you're worried about how much memory to reserve for the output string, just allocate 128 bytes. Then count digits after/before the decimal, if that was what you need.
Please use a smaller graphic in your signature.

ChrisLeslie

If you are asking for how to specify the number of decimal places you want to display, then you tell the "Decimal" parameter for FpuFLtoA.