[fpc-pascal] Why the difference in the rounded results?

Gabor Boros mlnglsts at bgss.hu
Fri Oct 15 11:49:59 CEST 2021


Hi All,

I got different results with 32bit vs. 64bit, 3.2.2 vs. 3.3.1, FPC vs. 
Delphi. Why?

var
   d1,d2:Double;

begin
   d1:=20.5;
   d2:=1.05;
   Writeln(RoundTo(d1*d2,-2));
   Writeln(SimpleRoundTo(d1*d2));
   d1:=28.9;
   Writeln;
   Writeln(RoundTo(d1*d2,-2));
   Writeln(SimpleRoundTo(d1*d2));
   d1:=21.5;
   Writeln;
   Writeln(RoundTo(d1*d2,-2));
   Writeln(SimpleRoundTo(d1*d2));
   Readln;
end.

- FPC 3.2.2 Win32

  2.1530000000000001E+001
  2.1530000000000001E+001

  3.0340000000000000E+001
  3.0340000000000000E+001

  2.2570000000000000E+001
  2.2570000000000000E+001

- FPC 3.2.2 Win64

  2.1520000000000003E+001
  2.1530000000000001E+001

  3.0340000000000007E+001
  3.0350000000000001E+001

  2.2570000000000004E+001
  2.2579999999999998E+001

- FPC 3.3.1 Win32

  2.1530000000000001E+001
  2.1530000000000001E+001

  3.0340000000000000E+001
  3.0340000000000000E+001

  2.2570000000000000E+001
  2.2570000000000000E+001

- FPC 3.3.1 Win64

  2.1520000000000003E+001
  2.1530000000000001E+001

  3.0340000000000007E+001
  3.0350000000000001E+001

  2.2570000000000004E+001
  2.2579999999999998E+001

- Delphi 10.4.2 Win32

  2.15300000000000E+0001
  2.15300000000000E+0001

  3.03400000000000E+0001
  3.03400000000000E+0001

  2.25800000000000E+0001
  2.25800000000000E+0001

- Delphi 10.4.2 Win64

  2.15200000000000E+0001
  2.15300000000000E+0001

  3.03400000000000E+0001
  3.03500000000000E+0001

  2.25800000000000E+0001
  2.25800000000000E+0001

Gabor


More information about the fpc-pascal mailing list