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

Bruce Carneal bcarneal at
Sun Aug 9 05:30:12 UTC 2020

On Saturday, 8 August 2020 at 22:13:57 UTC, Bruce Carneal wrote:
> Per the original post in this thread, the current compiler 
> doesn't convert decimal floating point literals to binary form 
> correctly in all normal cases.  Assuming people actually want 
> to be correct/consistent to the last bit wherever possible, 
> that should change.
> Additionally, the default library conversions should match 
> those of the compiler. They should also be correct/consistent.
> This could be accomplished by introducing Mir dependencies in a 
> few places but I think fully accredited copying is a better way 
> to go.  There is more to maintain, true, but accurate 
> conversion is fundamental in nature.  We're not talking about 
> some high level library here.  Hard to get right? Apparently.  
> Esoteric?  No.
> As to timing, if the subnormal update Ilya mentioned is very 
> close it would make sense to wait for that version.
> Side note: the truly persnickety/paranoid might favor hex 
> floating point literals but those are pretty hard on human 
> readers.  At least the conversion implementations should not 
> require heroics.

OTOH, this is pretty small potatoes when compared to other CTFE 
floating point discrepancies (no control of precision, all to 
'real' IIUC).  Maybe the best that can be done is to align the 
library with better practice.

More information about the Digitalmars-d-announce mailing list