
On Wed, Sep 1, 2021 at 10:23 AM Steven D'Aprano <steve@pearwood.info> wrote:
What doesn't work, for some definition of "doesn't", is everything else about floats: addition, subtraction, multiplication, conversion from decimal, etc. But *equality* is one of the few operations that works exactly.
Really, the only thing that BADLY doesn't work is conversion from decimal. All the others are accurate to within the available precision. The problem with binary floating point isn't equality; it's that humans assume that 0.1 is a precise value. We don't expect 0.33333 to be a precise representation of one third, yet we expect a computer to be able to store one tenth with perfect accuracy. That's where ALL the problems come from. In the classic demonstration that 0.1 + 0.2 != 0.3, the problem isn't equality, it's that none of those values is what you think it is. If I told you that 33/100 + 66/100 != 100/100, nobody would bat an eyelid. ChrisA