
Originally Posted by
tommo
How can they if it is an impossible/illogical equation?
They go into an "undefined" state. "undefined" is in quotes because it's mathematically undefined, but completely defined in code. You can not equate math undefined and computer undefined.
1/3 is not defined in computer terms.

Originally Posted by
IAmCoder
Code:
if (NaN) {return false;}
No, that will always go into the block.
NaN is defined to be created by:
Any mathematical operation with any of the parameters being NaN
0/0
+-inf/ +-inf
+-inf * 0
inf + -inf
powr(0, 0)
powr(1, inf)
powr(inf, 0)
sqtr(x) where x < 0
log(x) where x < 0
sin-1(x) where x < -1 or x > 1
cos-1(x) where x < -1 or x > 1
Any NaN is not equals to itself. A lot of newbie coders will see something like this in code
Code:
if (var != var) { /* do something */ }
and remove it because they think it is an impossible case, and it's not. To get really detailed, there is actually two NaN versions. 
And actually 1/0 does not go into the NaN state, it goes into the inf state.
Bookmarks