strtr wrote:
== Quote from Don (nos...@nospam.com)'s article
strtr wrote:
== Quote from bearophile (bearophileh...@lycos.com)'s article
But the bigger problem in your code is that you are performing operations on
NaNs (that's the default initalization of FP values in D), and operations on 
NaNs
are usually quite slower.

I didn't know that. Is it the same for inf?
Yes, nan and inf are usually the same speed. However, it's very CPU
dependent, and even *within* a CPU! On Pentium 4, for example, for x87,
nan is 200 times slower than a normal value (!), but on Pentium 4 SSE
there's no speed difference at all between nan and normal. I think
there's no speed difference on AMD, but I'm not sure.
There's almost no documentation on it at all.

Thanks!
NaNs being slower I can understand but inf might well be a value you want to 
use.

Yes. What's happened is that none of the popular programming languages support special IEEE values, so they're given very low priority by chip designers. In the Pentium 4 case, they're implemented entirely in microcode. A 200X slowdown is really significant.

However, the bit pattern for NaN is 0xFFFF..., which is the same as a negative integer, so an uninitialized floating-point variable has a quite high probability of being a NaN. I'm certain there's a lot of C programs out there which are inadvertantly using NaNs.

Reply via email to