Decimal string to floating point conversion with correct half-to-even rounding

9il ilyayaroshenko at
Wed Jul 8 00:50:52 UTC 2020

On Tuesday, 7 July 2020 at 23:56:45 UTC, kinke wrote:
> On Tuesday, 7 July 2020 at 23:52:05 UTC, 9il wrote:
>> On Tuesday, 7 July 2020 at 16:38:39 UTC, kinke wrote:
>>> 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.
> I've just opened a PR for DMD (and LDC too): 
>> Does this actually mean DMD wouldn't be able to compile itself 
>> with DigigtalMars C runtime?
> Sorry, I don't understand. - I think this excess precision was 
> at some point considered a feature (but probably only for D, 
> not for DigitalMars C), there's even a test making sure 0.9L 
> and 0.9 are parsed to the same compile-time value.

DMC strtod [1] isn't IEEE compatible. Just nitpick. Unlikely it 
is used to compile DMD thought.


More information about the Digitalmars-d-announce mailing list