[fpc-devel] FormatFloat bug
Burkhard Carstens
fpc at bcsoft.de
Tue May 29 21:27:50 CEST 2007
Am Dienstag, 29. Mai 2007 20:51 schrieb Graeme Geldenhuys:
> On 5/29/07, Joao Morais <post at joaomorais.com.br> wrote:
> > > Hi,
> > >
> > > Attached is a application that demonstrates a bug in FormatFloat.
> > > All tests pass when run under Delphi, but test four fails under
> > > Free Pascal.
> >
> > IMHO, fpc behaves correctly. 0.005 is closer than 0 instead 0.01.
> > If you try 0.00500000001, you will have 0.01, also correct.
>
> Normally you would round 5 or higher up so taking 0.005 to two
> decimal places would give you 0.01 which is what Delphi does! This is
> mathematically correct. It's got nothing to do with whether it is
> closer to zero or to one.
Try 0.015, that should round to 0.02. IIRC, it's "round-to-even", see
http://en.wikipedia.org/wiki/Rounding.
regards
Burkhard
More information about the fpc-devel
mailing list