4 ms·
Quite amazing how so many environments of floating point values make the mistake of treating them as equal. YAML 1.2 does the same thing: https://yaml.org/spec
by EdSchouten 3y ago
Quite amazing how so many environments of floating point values make the mistake of treating them as equal. YAML 1.2 does the same thing:
https://yaml.org/spec/1.2.2/#10214-floating-point https://yaml.org/spec/1.2.2/#10214-floating-point
- ilyt 3y agoBecause they are equal in real math
- Taniwha 3y agoYes but this is floating point - +0.0 represents all numbers between 0 and the smallest +ve FP number, -0.0 represents all numbers between 0 and the smallest -ve FP number - both can represent actual 0 - remember these can be generated by underflow so those meanings can be important in context
- zokier 3y agoFloats are not real numbers though
- deleted 3y ago[deleted]
- garbagecoder 3y agoThey are a way of approximating Real (the set not as an adjective) numbers, though. Real numbers are exact when they are equal to an integer or a rational, because, depending on how you construct them, either that's what the cut contains or that's where the series converges. And also because that's what the most common spec demands.
- recursive 3y agoFloats are a subset of the reals.
- yifanl 3y agofloating point math is math like any other, just with a vastly different number system. There are valid arguments on both side if we should hide or expose those differences in the implementation, but there's always going to be pretty big implications (i.e. the compiler behaviour mentioned here)
- murderfs 3y agoIs it surprising that so many environments that use IEEE 754 floating point numbers obey IEEE 754 on equality? IEEE 754-2008 5.11: "Comparisons shall ignore the sign of zero (so +0 = −0)."