Thank you very much for your effort!
Yes I compile with same version FPC 2.6.4, but important point is, that on *Windows 98*!

When I compile on Windows XP, I get same results as you for 2.6.4:
CW=4978
currency=-9.223372036854775808E+14
currency=-9.223372036854799990E+13
extended=-9.2233720368547758E+0014
string=-92233720368547,9999
int64=-9223372036854775808
double=-9.22337203685480E+017

But slightly different for 2.7.1 (on same PC):
CW=4978
currency=-9.223372036854775808E+14
currency=-9.223372036854799990E+13
extended=-9.22337203685477580811E+0014   <== HERE
string=-92233720368547,9999
int64=-9223372036854775808
double=-9.2233720368547994E+017  <== AND HERE
(which does not must indicate error, because there is no exact floating point representation of given currency value)

But my original question is why are different results for WinXP and Win98 with same compiler FPC 2.6.4 ?
It seems, that FPC on Win98 incorrectly stores currency constant in generated EXE file, so varible "c" is initialised with wrong value ...
(see my first email with results)

Thanks
-Laco.

> 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
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
-Laco.

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

Reply via email to