2
When trying to round to 4 decimal places the value 18,36735 by means of the function Formatfloat, the system generates the value 18.3673. How is this possible? It should not round up the value, generating 18.3674? At least in numerous other points of the system the function Formatfloat works as expected, but at this point is occurring this...
Anyway what I want to know is, This is some bug? Is it an expected behavior? And, how to resolve this situation?
Important details (interesting): If the rounded value is changed to 18,38735 the function Formatfloat round off to 18,387 as expected4.
I use Delphi XE7.
Exactly, it was this behavior that I expected, but as you can see in the image and explanation that I provided, it happened exactly the opposite. See in the image that the last decimal is 5, but has not rounded the penultimate decimal place to 4, previously kept the 3. Like?
– Andrey
Right! I ran a test " edit1.Text := formatFloat('0.0000',18.36735);" Worked normal. That is, the 3 turned 4. You are probably confusing comma(,) with dot(.).
– Fábio Furious
I still don’t understand, because this situation doesn’t make any sense. However, I noticed that the problem occurs when I try to round up a value that comes from a dataset, example: Formatfloat('0.0000',Cdsitens.Fieldbyname('VALUE'). Asfloat);
– Andrey
...has to see the conversion of values, the databases are standardized for the American parameters. Which normally replaces (,) by (.), also the date. Ours is dd.mm.yyyy, where the standard (American) is mm.dd.yyyy. In these cases we use Stringreplace ex: string := Stringreplace(value. Text, '. ', ', ', [rfReplaceAll]);
– Fábio Furious
I always thought that the rounding used was the banking (from 1.5 or 2.5 goes to 2, other values no limits follows this other scheme)
– Jefferson Quesado