[fpc-devel] More on rounding bug(?)

Chris Cheney cjc1 at cam.ac.uk
Mon Oct 2 20:09:56 CEST 2006


(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




More information about the fpc-devel mailing list