low precision floating point constants
Original Reporter info from Mantis: BeniBela @benibela
-
Reporter name: Benito van der Zander
Original Reporter info from Mantis: BeniBela @benibela
- Reporter name: Benito van der Zander
Description:
Some floating point constants are treated as single when they used to have more precision
Steps to reproduce:
begin
writeln(double(StrToFloat('1')) / double(StrToFloat('3.0')));
writeln(double(1 / double(3.0)));
writeln((1 / double(3.0)));
writeln(double(1 / 3));
writeln(double(1 / 3.0));
writeln(double(1 / 3.0):22:22);
writeln((1 / 3.0));
writeln((1 / single(3.0)));
end.
In 3.0.4 it prints very pretty:
3.3333333333333331E-001
3.3333333333333333E-001
3.3333333333333333E-001
3.3333333333333333E-001
3.3333333333333333E-001
0.3333333333333333300000
3.333333333E-01
3.333333333E-01
in trunk r47006 it prints:
3.3333333333333331E-001
3.3333333333333331E-001
3.3333333333333331E-001
3.3333333333333331E-001
3.3333334326744080E-001
0.3333333432674408000000
3.333333433E-01
3.333333433E-01
Guess the last two are valid ways to print a single 1/3, but why is double(1 / 3.0) calculated with single precision?
Mantis conversion info:
- Mantis ID: 37935
- OS: linux
- OS Build: opensuse
- Build: r47006
- Platform: amd64
- Version: 3.3.1