Am 11.06.2018 um 10:01 schrieb Michael Schnell:
 - the way of rounding is defined by the CPU hardware, even old Turbo Pascal executables do banker's rouding on modern hardware.

No, it does not depend on the hardware, but on the setting of $N. Turbo Pascal with $N+ rounds like FreePascal. But the default is $N-. In this mode Turbo Pascal always rounds up.

var
  a : real;
begin
  a := 35;
  writeln (round(a*1.1));
end.

FreePascal: 38
Turbo Pascal: 39

And when the compiler precalculates a constant expression, it always rounds up as well, regardless of $N.

Nobody expects that increasing a number by 10% will depend on whether the resulting number will be close to an even integer. That feels completely erratic.

This behaviour does have advantages in the special case of adding up many rounded numbers, but it ruins the graphics output of my software. It should at least be configurable. And in {$mode tp} it should behave like Turbo Pascal, because that's what this mode is made for.

 - SetRoundMode is not only dangerous, but does not help, anyway, as there is no mode defining the "intuitive " "non-banker rouding" method.

That's why I'm looking for a better solution. The the only *reliable* solution appears to be compiling a modified version of FreePascal.

Klaus
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to