[fpc-pascal] Inconsistent results currency - extended ?

Bruno Krayenbuhl kraybruno at bluewin.ch
Fri May 2 10:10:17 CEST 2014


Tested with FPC 2.6.4 .

LacaK are you sure you compile with the same version.

To me everything looks fine.

program test_Currency;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  SysUtils;

var
  s: string;
  c: currency;
  e: extended;
  d: double;
  i64: int64;

begin
  i64:=1 shl 63;
  c:=PCurrency(@i64)^; // Minimum representable currency
  d:=-922337203685479999;
  e:=c;
  i64:=PInt64(@c)^;

  writeln('CW=', Get8087cw());
  writeln('currency=', c);
  c:=-92233720368547.9999; // LacaK currency
  writeln('currency=', c);
  writeln('extended=', e);
  writeln('string=', currtostr(c));
  writeln('int64=', i64);
  writeln('double=', d);
  readln;
end.

Gives me :
CW=4978
currency=-9.223372036854775808E+14 -> Ok to me
currency=-9.223372036854799990E+13 -> Ok to me
extended=-9.2233720368547758E+0014
string=-92233720368547.9999 -> Ok to me
int64=-9223372036854775808
double=-9.22337203685480E+017

BrunoK




More information about the fpc-pascal mailing list