5 ms·
I'm a huge fan of this system, but it's worth pointing out that it doesn't have a single NaN, it has a single infinity with an undefined sign, modeling the proj
by addaon 5y ago
I'm a huge fan of this system, but it's worth pointing out that it doesn't have a single NaN, it has a single infinity with an undefined sign, modeling the projectively extended real numbers. NaN is a bit of an abomination; projective infinity is an uncommon beast, but one that can be worked with consistently. And yes, by pairing zero with infinity on opposite sides of the number ring, you get a symmetric system with no undefined or redundant encodings.
- Aardwolf 5y agoSigned infinity is useful for limits, and also for initial values of some algorithms, so missing them seems like a disadvantage. Also, it still has no total order, so keeps another messy part of IEEE floats
- GolDDranks 5y agoThere's an easy alternative: just use the MAX and MIN values. That's what you would do with integers anyway, in case of initial values. As for limits, if you need to express limits in a datatype for expressing a small subset of rational numbers, you've got the wrong tool for the job.
- GolDDranks 5y ago> Also, it still has no total order This is not true. It is defined to have the exact same ordering, bitwise, as two's complement integers. That means it has total order: the NaN is the most negative, then comes the negative numbers, then zero, and then positive numbers.
- eurasiantiger 5y agoNaN is a feature of dynamically typed languages; otherwise they would not be able to represent all outcomes of implicit coercion.
- spc476 5y agoAnd here I thought NaN was a definition from IEEE-754.
- forty 5y agoYes, I'm not sure what parent means. Even java double has NaN.
- wongarsu 5y agoNaN is a feature of IEEE floats to ensure that all arithmetic operations can always create a correct result. For example 0/0 has to evaluate to NaN, no other result would be mathematically correct. If there was no NaN the CPU would have to trigger a fault or return an incorrect result, both are undesirable.
- eurasiantiger 5y agoSo, today I learned something: the JavaScript critics are wrong at yet another thing.
- LinAGKar 5y agoIt crops up more in JavaScript since it doesn't have integers, and if you try to convert non-numeric string to a number you get a NaN
- GolDDranks 5y agoThey used to call it "infinity with an undefined sign", then "NaR" for "Not a Real" but in the latest papers I've seen they just call it NaN. But that's just a name, it's the projective infinity as you say. I agree that the IEEE NaN is an abomination.
- gbrown_ 5y agoIt still seems to be NaR here https://posithub.org/posit_standard4.12.pdf https://posithub.org/posit_standard4.12.pdf