Hi
I want to convert “qrysth.Fields[i].AsFloat” to a string so I use the following code:
FormatFloat(‘0.###############’,qrysth.Fields[i].AsFloat)
but I find the result string is 12.000000000000001 while qrysth.Fields[i].AsFloat is 12.00. I know FormatFloat actually not use 12.00 to do the convert, but use an infinite number of binary to do the convert. (like 0.1 in decimal system is 0.1, but it is an infinite number in binary system 0.00011001100…)
Is there other way I could get 12.00 in the case above? or 12.000000000000000 at least?
Then why not use AsString?
This will give you the best representation, as long as you’re not concerned about the exact width. If you are, use
FormatFloatwith the exact number of digits you need – in other words, if you’re looking for12.00, useFormatFloat('##.##', qrysth.Fields[i].AsFloat), or even betterCurrToStrandAsCurrency, as they automatically uses two digits after the decimal point.