[fpc-pascal] overloading function StrPLCopy
Bruno Krayenbuhl
kraybruno at bluewin.ch
Thu May 8 08:39:42 CEST 2014
You have troubled me seriously, so I have dug in the compiler source.
It appears that when parsing the source, Currency constants are cast to type
BestReal (EXTENDED on I386) before being converted to the 8 byte currency
written to the PPU or EXE or whatever is done. The combination of these
steps DO USE FPU instructions on the I386, the compiler does not use
SysUtils.StrToCurr to create the 8 bytes currency.
As a bean counter, the point that was really scaring me was whether
additions and subtractions of Currency's with Currency's would use the FPU.
It appears that the generated (ASM) code actually uses Int64 arithmetic's
for these 2 operations. Ouf...
I run FPC 2.6.4 on WinXP machine with an Intel Core 2 CPU 6400 @2.13 GHz s
Here after a program that should test if the compiler is run on a
problematic CPU
==============================================
program test_Currency_loop;
var
c:currency;
cAsInt:Int64;
// cAsInt64:Int64 absolute c;
ix:integer;
begin
c:=92233720368547;
cAsInt:=922337203685470000;
if Pint64(@c)^<>cAsInt then
WriteLn('Problematic CPU for Compiler'); // FPU error on machine running
the compiler Dbg stop point
writeln(c);
for ix:=1 to 9 do begin
c:=c+0.0001;
writeln(c);
end;
readln;
end.
==============================================
To test :
1-Compile and run on your XP machine. Copy the .EXE to your W98 machine and
run it. See the results.
2-Compile and run on your Win98 machine. Copy the W98 .EXE to your XP
machine and run it. See the results.
I pop my stack and go back to what I was working on.
Regards, Bruno
More information about the fpc-pascal
mailing list