Hi, I created the follow fpcUnit tests. For those that don't know fpcUnit, the AssertEquals takes three parameters: Failing message, Expected Value, Actual Value.
Now from the tests below, I am formatting all values to 2 decimal values. I expected all tests to pass, but it doesn't. Test 9 fails and said it expected 0.00 which is wrong. Rules for rounding. If a decimal is exactly halfway (5) or more, rounding goes up. If decimal is < 5, rounding goes down. This rules is proven by tests 5, 6, 7 and 8. So why is test 9 failing? Is this a bug? AssertEquals('Failing on 1', '0.10', FormatFloat('0.00', 0.1)); AssertEquals('Failing on 2', '0.01', FormatFloat('0.00', 0.01)); AssertEquals('Failing on 3', '0.00', FormatFloat('0.00', 0.001)); AssertEquals('Failing on 4', '0.50', FormatFloat('0.00', 0.5)); AssertEquals('Failing on 5', '0.01', FormatFloat('0.00', 0.0051)); AssertEquals('Failing on 6', '0.05', FormatFloat('0.00', 0.049)); AssertEquals('Failing on 7', '0.00', FormatFloat('0.00', 0.0049)); AssertEquals('Failing on 8', '0.05', FormatFloat('0.00', 0.045)); AssertEquals('Failing on 9', '0.01', FormatFloat('0.00', 0.005)); ---------------- Test Output ------------------- [graemeg-linux] FloatToStr > ./fpcunit_formatfloat -a --format=plain Test: TTestFormatFloat.TestFormat1 Failing on 9 expected: <0.01> but was: <0.00> List of failures: Failure: Message: TTestFormatFloat.TestFormat1: Failing on 9 expected: <0.01> but was: <0.00> Exception class: EAssertionFailedError Exception message: Failing on 9 expected: <0.01> but was: <0.00> ------------------ end ----------------------------- I am using FPC 2.1.1 (r4642) under Linux. Considering that I am writing Accounting Software, I am taking this as a critical bug! Regards, - Graeme - _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel