Should I just keep posting my findings in this thread? I hate to make a new thread for every problem I find.. <br><br>Anyway, on Page 150, this code fails:<br><br>auto f = (int i) {};<br>assert(is(f == function));<br><br>I've checked via typeid(), and f is a delegate by default, not a function. I've tested it both in a function's scope and in module scope, with the same results.<br>
<br><div class="gmail_quote">On Wed, Jul 28, 2010 at 10:56 PM, Rainer Schuetze <span dir="ltr"><<a href="mailto:r.sagitario@gmx.de">r.sagitario@gmx.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
Andrej Mitrovic wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Woops, I got confused. I was thinking about structs, not arrays.<div class="im"><br>
<br>
But yeah, in this case a float gets compared to a double and it seems to evaluate to false.<br>
</div></blockquote>
<br>
2.4 has no exact representation as a floating point value, as it is 2^^2*0.6, so the mantissa is 3/5. It is rounded after 24 bits for float, but after 53 bits for a double. As a result<br>
<br>
float f = 2.4; // approximately 2.4000001<br>
double d = 2.4; // approximately 2.3999999999999999<br>
assert(f == d);<br>
<br>
fails, because the comparison is done after converting the truncated float to double (as long as the compiler does not issue SSE instructions with single precision).<br>
<br>
In contrast, this<br>
<br>
assert(2.4 == 2.4f);<br>
<br>
passes, as the compiler keeps real precision until writing the value to memory and evaluates the expression at compile time.<br>
</blockquote></div><br>