float init 0 request

Walter Bright newshound2 at digitalmars.com
Fri Aug 14 21:28:54 UTC 2026


On 8/14/2026 7:02 AM, Richard (Rikki) Andrew Cattermole wrote:
> NaN's come in two flavors, signaling and non-signaling.
> 
> Originally D default initialized floats to signal, but that was changed as it 
> was producing an inconsistency that was a problem (I wasn't involved with this).

Signalling NaNs simply did not work unless you wrote your code in assembler. 
That's because the compiler itself would flip it to a quiet nan every time it 
was copied.


> If you try to do math on a signaling NaN it will throw a hardware exception, 
> just like doing a null dereference does.

No compiler I know implements this, because it's a nuisance. NaNs were invented 
for the 8087, and while it made sense on paper, in practice it didn't work out 
too well.


> A non-signaling NaN is good, because you can at least detect when something has 
> gone wrong, just not the source.
> 
> Silent corruption is always worse than detectable corruption.

We can agree on that!



More information about the Digitalmars-d mailing list