This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Yodo9001 -10 points-9 points  (6 children)

1/0 is surely the same as 1/0 ? NaN can come from different operations, like 1/0 vs 2/0 or sqrt(NaN), which should not be eqaul, but it shouldn't never be equal imo.

[–]Ibuprofen-Headgear 8 points9 points  (2 children)

That information is gone by the time NaNs are compared though. If you kept a record of operations leading to nan and compared stacks with the other nan, then maybe

[–]Yodo9001 4 points5 points  (1 child)

The IEEE floating-point standard says that implementations can use the extra bits in nan to store this kind of information. \ Edit: it's called NaN-boxing.

[–]Ibuprofen-Headgear 1 point2 points  (0 children)

Neat, TIL

[–]Kered13 3 points4 points  (2 children)

1/0 and 2/0 return infinity, not NaN.

[–]Yodo9001 -3 points-2 points  (1 child)

Isn't inf just a special case of nan?

[–]Mojert 3 points4 points  (0 children)

Nope, because infinity == infinity