Why float('Nan') == float('Nan') is False

אורי uri at speedy.net
Thu Feb 14 12:38:20 EST 2019


> Or even better, use None instead of nan.

++

On Thu, Feb 14, 2019 at 3:26 AM Joe Pfeiffer <pfeiffer at cs.nmsu.edu> wrote:

> uri at speedy.net writes:
>
> > 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.
>
> You would expect that to be true, but it is not.  There are in fact the
> same number of odd integers as integers, and the same number of primes
> as integers.  Counterintuitive but true.
>

I know it's a Python mailing list and not Math, and this thread is
off-topic. But anyway, it depends how you define "more". There are infinite
integers and odd numbers, and as I said you can't compare infinite
"numbers" of elements. But, the set of odd numbers is a subset of the set
of integers. If you take any big range, for example from 0 to google
(10**100) - there are more integers in this range than odd numbers. There
are integers which are not odd numbers but there are no odd numbers which
are not integers. The set of integers which are not odd numbers is
infinite. So in this sense, there are more integers than odd numbers. And
also, there are more odd numbers than prime numbers (there is one prime
number which is not odd, and many many odd numbers which are not prime).

> There are in fact the same number of odd integers as integers, and the
same number of primes as integers.

If you mean that the "number" of odd integers is equal to the "number"
of integers, it is not. They are both infinite and infinity is not a
number. Two sets can have the same cardinality even if one set contains
more elements than the other. At least in the sense I define "more". A
cardinality is equal to the number of elements only for finite sets. For
infinite sets the cardinality is not the number of elements, the number of
elements is infinite.



> --
> https://mail.python.org/mailman/listinfo/python-list
>


More information about the Python-list mailing list