<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<blockquote cite="mid:005e01cf638e$9235f7f0$b6a1e7d0$@org" type="cite">
<pre wrap=""> Your code does not even compile on
my 2.6.4 installation (no Lazarus).
Where does the currtostr function come from?
Apparently from sysutils unit.
</pre>
</blockquote>
Yes from SysUtils<br>
<br>
<blockquote cite="mid:005e01cf638e$9235f7f0$b6a1e7d0$@org" type="cite">
<pre wrap="">How is it 'included' without any uses clause?
I found no option that automatic
add unit sysutils.
Could you give us a source and a compilation command line
that does not require Lazarus use?
</pre>
</blockquote>
Source code attached.<br>
Command line parameters: -MObjFPC -Scghi -O1 -Twin32 -Pi386 -g -gl
-vewnhi -Filib\i386-win32 -Fu. -FUlib\i386-win32 -l<br>
(taken from Lazarus as I never have used only standalone compiler ,
without Lazarus IDE)<br>
<br>
========= PROGRAM ==============<br>
program test_Currency;<br>
{$mode objfpc}{$H+}<br>
uses<br>
{$IFDEF UNIX}{$IFDEF UseCThreads}<br>
cthreads,<br>
{$ENDIF}{$ENDIF}<br>
SysUtils;<br>
<br>
var<br>
s: string;<br>
c: currency;<br>
e: extended;<br>
d: double;<br>
i64: int64;<br>
<br>
begin<br>
c:=-92233720368547;<br>
d:=-92233720368547;<br>
e:=c;<br>
i64:=PInt64(@c)^;<br>
<br>
writeln('CW=', Get8087cw());<br>
writeln('currency=', c);<br>
writeln('extended=', e);<br>
writeln('string=', currtostr(c));<br>
writeln('int64=', i64);<br>
writeln('double=', d);<br>
readln;<br>
end. <br>
================================<br>
<br>
When I compile on Win98 and run (it does not depend if it is ran on
Win98 or XP or Vista) output is same:<br>
=========== OUTPUT 1 ===========<br>
CW=4978<br>
currency=-9.223372036854699520E+13<br>
extended=-9.2233720368546995E+0013<br>
string=-92233720368546,9952<br>
int64=-922337203685469952<br>
double=-9.22337203685470E+013<br>
================================<br>
It seems (based on "i64" variable), that currency "c" is wrong
initialised with "-92233720368546.9952"<br>
On other side double is correct "-92233720368547"<br>
<br>
When I compile on Win Vista and run (it does not depend if it is Win98
or XP or Vista) output is correct (as expected):<br>
=========== OUTPUT 2 ============<br>
CW=4978<br>
currency=-9.223372036854700000E+13<br>
extended=-9.2233720368547000E+0013<br>
string=-92233720368547<br>
int64=-922337203685470000<br>
double=-9.22337203685470E+013<br>
================================<br>
<br>
Thanks<br>
-Laco.<br>
<blockquote cite="mid:005e01cf638e$9235f7f0$b6a1e7d0$@org" type="cite">
<pre wrap="">
Pierre Muller
</pre>
<blockquote type="cite">
<pre wrap="">-----Message d'origine-----
De : <a class="moz-txt-link-abbreviated" href="mailto:fpc-pascal-bounces@lists.freepascal.org">fpc-pascal-bounces@lists.freepascal.org</a> [<a class="moz-txt-link-freetext" href="mailto:fpc-pascal">mailto:fpc-pascal</a>-
<a class="moz-txt-link-abbreviated" href="mailto:bounces@lists.freepascal.org">bounces@lists.freepascal.org</a>] De la part de LacaK
Envoyé : mardi 29 avril 2014 10:23
À : FPC-Pascal users discussions
Objet : [fpc-pascal] Inconsistent results currency - extended ?
Hi,
I catch strange behavior, which I can not understand ;-)
I have 2 PC on both I have installed Lazarus 1.2.2 + FPC 2.6.4
(official
release)
1st PC has Windows 98 2nd PC has Windows Vista (32 bit)
I have this program:
=============================
var
c: currency;
e: extended;
begin
c:=-92233720368547;
e:=c;
writeln('CW=', Get8087cw(), ' currency=', c, ' extended=', e, '
string=', currtostr(c));
=============================
When I compile on 1st PC (Win98) and run it on 1st or 2nd PC I get this
result:
CW=4978 currency=-9.223372036854699520E+13
extended=-9.2233720368546995E+0013 string=-92233720368546,9952
When I compile on 2nd PC (Win Vista) and run on 1st or 2nd PC I get
(expected) result:
CW=4978 currency=-9.223372036854700000E+13
extended=-9.2233720368547000E+0013 string=-92233720368547
How is it possible?
Is compiled code somehow affected by platform on which is compilation
performed?
Thanks
-Laco.
_______________________________________________
fpc-pascal maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a>
</pre>
</blockquote>
<pre wrap=""><!---->_______________________________________________
fpc-pascal maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a>
</pre>
</blockquote>
<br>
</body>
</html>