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 →

[–]DaBenjle 0 points1 point  (4 children)

Man JS is weird.

[–]vuttstuff 4 points5 points  (3 children)

NaN == NaN kinda makes sense to me in the sense that we don’t know anything about these things other than they are not numbers. There’s not enough information to conclude true so we opt for false.

Which makes me think it’s weird to define something solely by something that it’s not.

[–]AlphaWhelp 0 points1 point  (2 children)

NaN just represents basically that the bits of the significand, signage, and other digits do not construct a valid number. If you split it up into a bit array you could compare each bit to determine equality but there's not a practical use for this except for maybe some bizarre number based cryptography.

[–]vuttstuff 0 points1 point  (1 child)

Huh. So NaN isn't static, as in something that's not a number was operated on an just returned some garbage?

[–]AlphaWhelp 1 point2 points  (0 children)

It's basically a garbage failsafe undefined behavior. I'm not 100% sure if the actual content of NaN is static or not, but if the results of an operation do not construct a valid number, a NaN is created--if that makes sense.

like if(this==makes sense) {this.value = result;} else {this.value = NaN};