[fpc-devel] Wrong floating point Currency calculations
Ondrej Pokorny
lazarus at kluug.net
Thu Feb 7 17:49:49 CET 2019
More info: if I use an Integer variable or even an Integer constant the
results are correct:
program Project1;
var
C0, C1, C2, C3, C4: Currency;
D0: Double;
I0: Integer;
begin
I0 := 4736;
C0 := I0;
D0 := C0;
C1 := C0 * 8 / 72 * 25.4 / 2048;
C2 := D0 * 8 / 72 * 25.4 / 2048;
C3 := I0 * 8 / 72 * 25.4 / 2048;
C4 := 4736 * 8 / 72 * 25.4 / 2048;
Writeln(C1);
Writeln(C2);
Writeln(C3);
Writeln(C4);
Readln;
end.
The wrong result comes only if a Currency variable is involved in the
computation.
Ondrej
More information about the fpc-devel
mailing list