Trying to round off double values to two decimal places using function FormatFloat
(Format string '0.##'
).
Below are the input
and output
values
231.545 -> 231.54 (but expected output is 231.55)
2.315 -> 2.31 (but expected output is 2.32)
23.045 -> 23.05 (gives expected output 23.05)
23.145 -> 23.14 (but expected output 23.15)
23.245 -> 23.25 (gives expected output 23.25)
23.345 -> 23.34 (but expected output 23.35)
23.445 -> 23.45 (gives expected output 23.45)
23.545 -> 23.55 (gives expected output 23.55)
23.645 -> 23.65 (but expected output 23.64)
23.745 -> 23.75 (gives expected output 23.75)
23.845 -> 23.84 (but expected output 23.84)
23.945 -> 23.95 (gives expected output 23.95)
why this strange behaviour happening? am using Delphi 7.