3 ms·
> You cannot use equality in floating point. Sure you can. 1.0 + 2.0 == 3.0. There's a lot of gotchas, but it is possible to make useful comparisons.
by slavik81 6y ago
> You cannot use equality in floating point.
Sure you can. 1.0 + 2.0 == 3.0. There's a lot of gotchas, but it is possible to make useful comparisons.
- worik 6y agoNo it does not, no it is not possible to use equality comparisons usefully in FP arithmetic
- slavik81 6y agoIf that were true, they wouldn't have defined the equality operators for floating point types. Some numbers are exactly representable and some numbers are not [1]. It's difficult, but you can in fact reason about the exact results of floating point calculations. https://news.ycombinator.com/item?id=1847462 https://news.ycombinator.com/item?id=1847462