Validity of checking exact value of preset double
<p>I sometimes do the following in my code when I am being lazy:</p>

<pre><code>double d = 0;
 ...
if( condition1 ) d = 1.0;

...
if (d == 0) { //not sure if this is valid
}
</code></pre>

<p>can I always count on the fact that if I set a <code>double</code> to be <code>0</code> I can later check in the code for it with <code>d == 0</code> reliably? </p>

<p>I understand that if I do computations on <code>d</code> in the above code, I can never expect <code>d</code> to be exactly <code>0</code> but if I set it, I would think I can. All my testing so far on various systems seem to indicate that this is legitimate.</p>
