[fpc-pascal] SimpleRoundTo behaviour
Bart
bartjunk64 at gmail.com
Tue Apr 8 23:59:37 CEST 2014
Hi,
Is this a bug in fpc?
(tested with 2.6.4)
program test;
{$ifdef fpc}{$mode objfpc}{$endif}
{$H+}
uses
Classes, SysUtils, Math;
var
S: Single;
E: Extended;
D: Double;
begin
writeln('Single');
S := SimpleRoundTo(12345,3);
writeln(S);
S := RoundTo(12345,3);
writeln(S);
writeln;
writeln('Double');
D := SimpleRoundTo(12345,3);
writeln(D);
D := RoundTo(12345,3);
writeln(D);
writeln;
writeln('Extended');
E := SimpleRoundTo(12345,3);
writeln(E);
E := RoundTo(12345,3);
writeln(E);
writeln;
writeln('FPC''s pick');
writeln(SimpleRoundTo(12345,3));
writeln(RoundTo(12345,3))
end.
Output comiled with Delphi 7
Single
1.20000000000000E+0004
1.20000000000000E+0004
Double
1.20000000000000E+0004
1.20000000000000E+0004
Extended
1.20000000000000E+0004
1.20000000000000E+0004
Delphi's pick
1.20000000000000E+0004
1.20000000000000E+0004
(It seems D7 only returns Extended)
Output compiled with fpc 2.6.4
Single
1.199999902E+04
1.200000000E+04
Double
1.19999990234375E+004
1.20000000000000E+004
Extended
1.1999999023437500E+0004
1.2000000000000000E+0004
FPC's pick
1.199999902E+04
1.200000000E+04
Bart
More information about the fpc-pascal
mailing list