On Tue, Aug 31, 2021 at 12:35:05PM -0700, Nick Parlante wrote: > You will be relieved to know that we have great fun showing them how == > does not work for floating point numbers. It is super memorable how that > all comes unglued.
Of course `==` works for floating point numbers. For floats, `x == y` returns True if and only if: - x and y are both zeroes - x and y are both +INF - x and y are both -INF - or x and y have the same numeric value. In other words, it is the intuitive and correct meaning of "equals" for all numbers capable of being represented as a float. People who remember floating point maths on computers prior to the widespread adoption of IEEE-754 will know that this is actually quite a big deal, and not something to sneer at. 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. -- Steve _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/I3XVILQC5KRXXLJ6DCHRKFKCLBLBNP66/ Code of Conduct: http://python.org/psf/codeofconduct/