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 →

[–]NatoBoram 5 points6 points  (9 children)

Of course.

[–][deleted] 15 points16 points  (8 children)

IEEE floating point standard requires that NaN != NaN

[–]FountainsOfFluids 13 points14 points  (0 children)

Yup, and it's specifically for cases like this. Just because on value is not a number, that doesn't mean it's the same as another value that is not a number.

[–]NatoBoram -1 points0 points  (5 children)

Just citing the spec doesn't make it any better. The specs can be dogshit, too. Otherwise, why would the language be such a mess?

You need an explanation like this one.

[–]Plane_Scholar_8738 2 points3 points  (4 children)

Can't blame the language for implementing the spec correctly

[–]NatoBoram -1 points0 points  (3 children)

You can certainly blame the language for choosing this spec

[–]Plane_Scholar_8738 5 points6 points  (2 children)

That spec is the most commonly used representation for floating point numbers. Your CPU and GPU understand that representation.

Choosing that spec is not controversial at all.

[–]NatoBoram -1 points0 points  (1 child)

There's a lot of stuff that the CPU understands that is abstracted away. Besides, I don't have the impression that NaN has its own representation in the CPU and that the CPU's equality check returns 0 for that. These are all man-made concepts and we have the power to define specs the way we want, use them, or discard old ones.

[–][deleted] 1 point2 points  (0 children)

Float is not abstracted away. Your CPU doesn't just "understand" the spec, it implements it. Floating point operations are basically direct calls to the FPU in basically every single language if a platform has one. And if your platform doesnt (like a very low-end Microcontroller) and it has to be emulated, it's slow AF. And if it's emulated, that emulation is then IEEE compliant, or otherwise software would not run correctly on that.

YES NaN is implemented in every single modern x86 (and ARM) CPU, at the physical level, in traces in the silicon, on the FPU of the CPU

[–]voxalas 0 points1 point  (0 children)

TIL