floating point - nan initializers
Anders F Björklund
afb at algonet.se
Sun Feb 19 11:33:07 PST 2006
Walter Bright wrote:
> That's right. The default initialization is *not* about being convenient or
> a shorthand. It's about being an aid to writing bug free code.
So it's an error to use ints before they're initialized ?
I thought it was "OK" to assume they all started at zero...
You know, like in: http://www.digitalmars.com/d/wc.html ;-)
> If there was a nan value for ints, that would be the default initialization
> for that, too. I'd love it if you could set a bit for a memory address that
> is cleared when the address is written to, and generates a hardware fault if
> it is read with that bit set. But there is no such thing, and nan is the
> best we can do otherwise.
So if the int.init is ever changed to something "nan"-ish, like
-1 or 0xDEADBEEF or something, it could stop to work later on ?
Guess this means to start using an "= 0;" explicit init value.
--anders
More information about the Digitalmars-d
mailing list