On Saturday, 4 July 2020 at 20:35:48 UTC, Walter Bright wrote:
On 6/21/2020 8:24 AM, 9il wrote:
So excited to finally announce we can correctly parse
floating-point numbers according to IEEE round half-to-even
(bankers) rule like in C/C++, Rust, and others.
Great work! Would you like to add it to dmd?
AFAIU, the 'problem' is that *all* floating-point literals are
parsed as real_t values, which for DMD is x87 real (usually using
the host C runtime's `strtold`). When emitting them as double or
float literals, the compiler converts these values to a lower
precision, where the increased intermediate precision might break
the 'banker's rule'.
So wouldn't the trivial 'fix' be using `strtod` for double
literals and `strtof` for floats? [For LDC, we wouldn't rely on
the host C runtime or a mir implementation, but use LLVM
facilities anyway.]