[fpc-pascal] round(2.5)=2

Michael Schnell mschnell at lumino.de
Mon Jun 11 10:01:13 CEST 2018


There has been a long winding discussion on the German Forum.

IMHO this is not really relevant, as relying on the exact value of a 
real number is erroneous, anyway. So a real number never can be 
considered to *exactly* *be* 1.5, but just somewhere nearby, and hence 
it's not legal to predict hat it is rounded to.

Moreover results of the discussion were:

  - the way of rounding is defined by the CPU hardware, even old Turbo 
Pascal executables do banker's rouding on modern hardware.
  - SetRoundMode is not only dangerous, but does not help, anyway, as 
there is no mode defining the "intuitive " "non-banker rouding" method.
  - (some versions of) Turbo Pascal had a soft-real library that did 
"intuitive" rounding.

-Michael



More information about the fpc-pascal mailing list