[fpc-devel] Wrong floating point Currency calculations
    Ondrej Pokorny 
    lazarus at kluug.net
       
    Thu Feb  7 17:33:53 CET 2019
    
    
  
Hello,
when doing floating point calculations with Currency, the results are wrong.
Example:
program Project1;
var
   C0, C1, C2: Currency;
   D0: Double;
begin
   C0 := 4736;
   D0 := C0;
   C1 := C0 * 8 / 72 * 25.4 / 2048;
   C2 := D0 * 8 / 72 * 25.4 / 2048;
   Writeln(C1);
   Writeln(C2);
end.
FPC 3.2 (current trunk) returns different results for C1 and C2:
  6.423600000000000000E+00
  6.526400000000000000E+00
Delphi XE2 returns equal results for C1 and C2:
  6.52640000000000E+0000
  6.52640000000000E+0000
Is this a known bug?
(Btw. I tested on win32.)
Ondrej
    
    
More information about the fpc-devel
mailing list