I'm using the Str function in Delphi 6 (to be able to ignore locale differences and make sure the decimal separator is always period) and when I have a Double type variable and set the Decimals indicator to 12, I can get strange results. If the Double type variable holds the value 270000 (Frac = 0), the call to Str results in a string like '270000.000000000032', i.e. it for some reason adds some decimals to the very end. Can this be a problem with floating point accuracy or something similar, and what would be a good solution to this? However, this seems to be tied to perhaps something else that has been done with the variable, since when I try to create a reduced code like the one attached, this error does not occur. In my actual code the ActVal comes from other variables and has had a life of its own before, so something in there is probably causing this, but the end result still is, that the debugger shows the value as 270000 without decimals and even a (Frac(ActVal) = 0) test evaluates to true, and still the resulting S ends with 32.
ActVal : Double;
ActVal := 270000;