On Saturday, 19 September 2020 at 21:53:34 UTC, mw wrote:
On Thursday, 20 June 2019 at 07:57:25 UTC, KnightMare wrote:
imo NaN is useless, weird and unusual coz integrals and
pointers are "all bits zeroes" but float and chars are "all
bits ones". WTF? its strange that bool.init is false in such
.init = "all zeroes" can be faster initialize any block of
I have the same question, why float/double are init to NaN,
instead of 0? as other post-C++ language does? e.g Java, C# ...
What's the reason for this design decision?
The default init values in D are intended to stand out if you're
looking at a printf dump or a debugger. NaN for float double, and
invalid UTF values for char/wchar/dchar were intentionally
chosen. For the integrals, there are no invalid values, so we're
stuck with 0.