<div class="gmail_quote">On Thu, Jun 7, 2012 at 6:50 PM, Minas <span dir="ltr"><<a href="mailto:minas_mina1990@hotmail.co.uk" target="_blank">minas_mina1990@hotmail.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">

I agree that the default value for floats/doubles should be zero. It feels much more natural.<br></blockquote><div> </div><div>The point is to make sure code is correct. Initializing your variables should be what feels natural. Leaving then uninitialized is bad style, bad practice, and generally a bad idea. If getting stung by a float initializing to NaN is what it takes to make that happen, so be it. </div>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
<br>
I think the problem here is that people are thinking about some stuff too much. D is a rather new language that wants to be practical. Floats defaulting to NaN is NOT practical FOR MOST PEOPLE when at the same time I write:</blockquote>

<div> </div><div>Actually, as far as I know, floats have been initialized to NaN since D first appeared in 2001. This isn't news. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">

 </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
<br>
int sum;<br>
<br>
for(...)<br>
  sum += blah blah blah<br>
<br>
And it works.<br></blockquote><div>In any other systems language, this would be undefined behavior. D is simply trying to make initialization bugs as obvious as possible. With ints, the best we can do is 0. With floats, NaN makes it better.</div>

</div>