[fpc-pascal] Currency constant wrongly stored in generated EXE ? was: Re: Inconsistent results currency - extended ?

LacaK lacak at zoznam.sk
Tue May 6 14:33:51 CEST 2014


Bruno Krayenbuhl  wrote / napĂ­sal(a):
>  
> 2 - Difference between 2.6.4 on Win98 and WinXP.
>    I suspect that these 2 are on different computers and thus do not 
> have exactly the same floating point unit.
Yes Win 98 is on PC with Intel Pentium 4 CPU and Win XP on PC with Intel 
Core 2 Duo CPU

But lets look again at our "simplified" program:
=========================
var
  c: currency;
  i64: int64;
begin
  c:=92233720368547;
=========================
Here I stop and let's look at assembler of  "c:=92233720368547" :
--------------------------------------
00401543 a1c0204100               mov    0x4120c0,%eax       // low 4 
bytes; EAX=-859001088 resp. 0xccccaf00 = 3435966208
00401548 a300604100               mov    %eax,0x416000
0040154D a1c4204100               mov    0x4120c4,%eax       // high 4 
bytes; EAX=214748364
00401552 a304604100               mov    %eax,0x416004
--------------------------------------
So currency value is: 2^32*214748364 + 3435966208 = 922337200249503744 + 
3435966208 = 922337203685469952
Not as expected 922337203685470000 !
(this is on Win 98 PC !, on Win XP PC are values in EAX correct 
3435966256, 214748364)

So constant "92233720368547" which is part of generated EXE (I think) is 
wrong parsed or interpreted or what and stored wrongly in output EXE file.
But why it happens ? What part of compiler is responsible for parsing 
constants in source code and translating them to binary form in which is 
stored in output EXE file ?
Does compiler links any external DLLs which probably may change FPU 
control word (precision or so) ?
Does compiler first converts value to floating point representation ant 
then back to currency or ?

Thanks
-Laco.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140506/b5560097/attachment.html>


More information about the fpc-pascal mailing list