[fpc-devel] Rounding inconsistent (critical)

Graeme Geldenhuys graemeg.lists at gmail.com
Mon Oct 2 12:59:45 CEST 2006


I also ran the exact example given on the Wikipedia site and I also got errors.

  AssertEquals('Failing on 1', '3.02', FormatFloat('0.00', 3.016));
  AssertEquals('Failing on 2', '3.01', FormatFloat('0.00', 3.013));
  AssertEquals('Failing on 3', '3.02', FormatFloat('0.00', 3.015));
  AssertEquals('Failing on 4', '3.04', FormatFloat('0.00', 3.045));
  AssertEquals('Failing on 5', '3.05', FormatFloat('0.00', 3.04501));


Test 1: Passed
Test 2: Passed
Test 3: Passed
Test 4: Failing on 4 expected: <3.04> but was: <3.05>
Test 5: Passed


Regards,
  - Graeme -



On 02/10/06, Graeme Geldenhuys <graemeg.lists at gmail.com> wrote:
> On 02/10/06, Vincent Snijders <vsnijders at quicknet.nl> wrote:
> > >  AssertEquals('Failing on 10', '0.44', FormatFloat('0.00', 0.445));
> > >  AssertEquals('Failing on 11', '0.46', FormatFloat('0.00', 0.455));
>
> Sorry, I shouldn't have used the work expected in my description, as
> that does confuse things a bit. You are right with your assumption
> though.
>
> Test 10:  I expected 0.44   but got  0.45 from FormatFloat()
> Test 11:  I expected 0.46   but got  0.45 from FormatFloat()
>
>
> Now using your tests:
>
>   AssertEquals('Failing on 6', '0.12', FormatFloat('0.00', 0.125));
>   AssertEquals('Failing on 7', '0.38', FormatFloat('0.00', 0.375));
>
>  Test 6: Passed
>  Test 7: Failing on 7 expected: <0.38> but was: <0.37>
>
>
> I gather that this confirms a bug in FPC's banker's rounding.
>
> Regards,
>   - Graeme -
>


-- 
There's no place like 127.0.0.1



More information about the fpc-devel mailing list