Reputation: 3338
In this code:
FormatFloat('0.##########',XX.AsFloat)
If the value XX in the database is 12.12345, what value will it return?
The number of # is more than 5 decimal places, so will it do extra rounding?
I can't find a doc for this FormatFloat
.
I'd also like to know what .AsFloat
does.
Upvotes: 1
Views: 1846
Reputation: 68902
When I run it I get find FormatFloat('0.###########',12.123456) = 12.123456
. So there are no trailing spaces, and no extra 0s. You can't extrapolate that one case to a general rule though because there are LOTS of floating point values that can't be represented exactly in binary. So the general answer is you'll get a number with at least one digit to the left of where the decimal would have been, and you'll either get a decimal place and a variable number of decimals on the right side, or no decimal place at all.
There is no reasonable way to predict it other than having an intimate knowledge of IEEE Floating Point encoding, and the limitations of binary floating point numeric storage. Try the above with 1.0 for example, and you get '1' and no decimal places.
AsFloat is a method of an object, and if you want to know how it's implemented, and as you haven't told us what type XX is, we can't tell you that. But you don't need to ask us, you can just Ctrl+Click on it.
Another day, another referral to What Every Computer Scientist Should Know About Floating-Point Arithmetic
Upvotes: 9