[Issue 14958] Casting a double to ulong sometimes produces wrong results
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Aug 25 05:22:37 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14958
yebblies <yebblies at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
CC| |yebblies at gmail.com
Resolution|--- |INVALID
--- Comment #3 from yebblies <yebblies at gmail.com> ---
This is working to spec. Please re-open as an enhancement request if you feel
it's necessary.
The way it goes, is that floating-point hardware does not give us the
guarantees you want. E.g. a 32-bit multiply-and-add instruction might use 36
bit precision internally.
Given this, we have two choices:
1. Avoid floating-point hardware
2. Allow intermediates to use higher precision than operands
1 comes with an obvious performance penalty.
2 causes some confusion.
DMD calculates everything at 80-bit precision at compile time, and the spec
allows it.
Identical floating point calculations can also produce different results thanks
to differing levels of inlining and exact register allocation.
--
More information about the Digitalmars-d-bugs
mailing list