Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-04

SimpleRoundTo behaviour

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bart

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