Decimal string to floating point conversion with correct half-to-even rounding
ilyayaroshenko at gmail.com
Tue Jul 7 23:52:05 UTC 2020
On Tuesday, 7 July 2020 at 16:38:39 UTC, kinke wrote:
> On Saturday, 4 July 2020 at 20:35:48 UTC, Walter Bright wrote:
>> On 6/21/2020 8:24 AM, 9il wrote:
>> 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.]
This should work if the C runtime handles the values correctly.
Does this actually mean DMD wouldn't be able to compile itself
with DigigtalMars C runtime?
More information about the Digitalmars-d-announce