Why float('Nan') == float('Nan') is False
uri at speedy.net
Wed Feb 13 16:27:47 EST 2019
uri at speedy.net
On Wed, Feb 13, 2019 at 10:20 PM Chris Angelico <rosuav at gmail.com> wrote:
> On Thu, Feb 14, 2019 at 7:12 AM Test Bot <onlinejudge95 at gmail.com> wrote:
> > This definition of NaN is much better in mentally visualizing all the so
> > called bizarreness of IEEE. This also makes intuitive that no 2 NaN will
> > equal just as no 2 infinities would be equal. I believe in a
> > my own creation) that any arithmetic on a data type of NaN would be
> > to any set of operations on the set of Infinities.
> Why would no two infinities be equal? In mathematics, there's one
> best-known infinity (aleph null, aka the number of counting numbers),
> and many many infinities are provably equal to it. (Others are
> provably NOT equal to it, like the number of real numbers.) There's
> nothing wrong with saying "there are as many prime numbers as there
> are odd numbers", or equivalently that "the size/cardinality of the
> set of primes is equal to the size of the set of odd numbers" . And
> both Python and IEEE agree:
There are more integers than odd numbers, and more odd numbers than prime
numbers. An infinite set may be a subset of another infinite set although
they may both have the same cardinality. Or in other words, the number of
elements in each set is not equal. One has more elements than the other.
AND, by induction you can also prove that the other one has more elements
than the first one. So the number of elements in two infinite sets can't be
equal. Even, if you compare the same set to itself.
> >>> float("inf") == float("inf")
> NaN and infinity are quite different concepts, and they behave very
>  I'm sure someone will point out something pedantically wrong in
> what I said, but certainly the sets have the same cardinality.
More information about the Python-list