Bug 22740 – float and double literals should be rounded to their precision

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-02-05T23:15:15Z
Last change time
2024-12-13T19:20:47Z
Keywords
pull
Assigned to
No Owner
Creator
Walter Bright
See also
https://issues.dlang.org/show_bug.cgi?id=9937
Moved to GitHub: dmd#20048 →

Comments

Comment #0 by bugzilla — 2022-02-05T23:15:15Z
The following: import std.stdio; const float f = 0.2f; void main() { writeln(f - 0.2); } prints 0, but it should print 2.98023e-09
Comment #1 by ibuclaw — 2022-02-05T23:33:22Z
The introduction of `core.math.toPrec' was made to specifically handle this case, as compile-time floats are stored at full precision.
Comment #2 by dlang-bot — 2022-02-06T01:04:45Z
@WalterBright created dlang/dmd pull request #13613 "fix Issue 22740 - float and double literals should be rounded to thei…" fixing this issue: - fix Issue 22740 - float and double literals should be rounded to their precision https://github.com/dlang/dmd/pull/13613
Comment #3 by robert.schadek — 2024-12-13T19:20:47Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20048 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB