Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2006-10

More on rounding bug(?)

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Chris Cheney

(I am sorry to start a different thread but, from the location that I have a working FPC, I do not have access to the original posts.)

1. Delphi 6, 7, and TurboDelphi define the Round function as using Banker's Rounding by default. However, the Round function only rounds to an integer. (Beware, Delphi 3's Round function is defined to round up in magnitude from the midpoint value)

2. In practice, FPC and Delphi deliver different results for FormatFloat('0.00', 0.375).

3. AFAICS, Delphi does not define how FormatFloat performs its rounding. However, it appears to use Banker's Rounding.

4. Delphi also provides RoundTo which is defined to use Banker's Rounding by default (doubtless, this is used by its FormatFloat) but FPC does not appear to have RoundTo (or, at least, I haven't found it yet).

<pedant>Only if FormatFloat in FPC is defined to use Banker's Rounding, is there a bug; otherwise there is "merely" an infelicity.</pedant>

Chris

Reply by email