RE: FW: Why float('Nan') == float('Nan') is False

2019-02-15 Thread Avi Gross
ot; went to "Nan" So, indeed, the transcript lied. I will be more careful. -Original Message- From: Python-list On Behalf Of Gregory Ewing Sent: Friday, February 15, 2019 3:51 AM To: python-list@python.org Subject: Re: FW: Why float('Nan') == float('Nan&#

Re: FW: Why float('Nan') == float('Nan') is False

2019-02-15 Thread Gregory Ewing
Avi Gross wrote: I can see why you may be wondering. You see the nan concept as having a specific spelling using all lowercase and to an extent you are right. No, he's talking about this particular line from the transcript you posted: >>>float(" nan") > Nan This suggests that the interpreter

Re: FW: Why float('Nan') == float('Nan') is False

2019-02-14 Thread Chris Angelico
On Fri, Feb 15, 2019 at 4:15 PM Avi Gross wrote: > > > You shouldn't be testing floats for identity. > > I am not suggesting anyone compare floats. I repeat that a nan is not > anything. Now as a technicality, it is considered a float by the type > command as there is no easy way to make an int th

RE: FW: Why float('Nan') == float('Nan') is False

2019-02-14 Thread Avi Gross
', 'fromhex', 'hex', 'imag', 'is_integer', 'real'] >>> id(numpy.nan) 57329632 This time that same address is reused: >>> m = numpy.nan >>> id(m) 57329632 >>> n = numpy.nan >>> id(n) 57329632 So the nu

Re: FW: Why float('Nan') == float('Nan') is False

2019-02-14 Thread Chris Angelico
On Fri, Feb 15, 2019 at 2:37 PM Avi Gross wrote: > But here is a curiosity. The numpy add-on package has a nan that is UNIQUE > so two copies are the same. Read this transcript and see if it might > sometimes even be useful while perhaps confusing the heck out of people who > assume all nans are t

RE: FW: Why float('Nan') == float('Nan') is False

2019-02-14 Thread Avi Gross
n) >>> numpya == numpyb False >>> numpya is numpyb True -Original Message- From: Python-list On Behalf Of Grant Edwards Sent: Thursday, February 14, 2019 6:15 PM To: python-list@python.org Subject: Re: FW: Why float('Nan') == float('Nan') is Fal

Re: FW: Why float('Nan') == float('Nan') is False

2019-02-14 Thread Grant Edwards
On 2019-02-14, Avi Gross wrote: > I experimented a bit: > float("nan ") > nan float(" nan") > Nan float(" nAn") > nan That's curious. I've never seen "Nan" before. What version of Python are you using? -- Grant Edwards grant.b.edwardsYow! NANCY!! Why i

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

2019-02-14 Thread Avi Gross
forum, some things in python are best not to be touched directly but with specially created access functions that can handle them well. -Original Message- From: Python-list On Behalf Of ast Sent: Thursday, February 14, 2019 2:00 AM To: python-list@python.org Subject: Re: Why fl

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

2019-02-14 Thread Joe Pfeiffer
Chris Angelico writes: > > Or even better, use None instead of nan. There's nothing in Python > says you have to (ab)use a floating-point value as a signal. Or use > "while True" and add a break if the exception isn't thrown. Good point. -- https://mail.python.org/mailman/listinfo/python-list

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

2019-02-14 Thread אורי
> Or even better, use None instead of nan. ++ On Thu, Feb 14, 2019 at 3:26 AM Joe Pfeiffer wrote: > u...@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

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

2019-02-14 Thread Chris Angelico
On Fri, Feb 15, 2019 at 3:56 AM Joe Pfeiffer wrote: > > ast writes: > > > Le 13/02/2019 à 14:21, ast a écrit : > >> Hello > >> > >> >>> float('Nan') == float('Nan') > >> False > >> > >> Why ? > >> > >> Regards > >> > > > > Thank you for answers. > > > > If you wonder how I was trapped with it, h

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

2019-02-14 Thread Joe Pfeiffer
ast writes: > Le 13/02/2019 à 14:21, ast a écrit : >> Hello >> >> >>> float('Nan') == float('Nan') >> False >> >> Why ? >> >> Regards >> > > Thank you for answers. > > If you wonder how I was trapped with it, here > is the failing program. > > > r = float('Nan') > > while r==float('Nan'): >

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

2019-02-13 Thread ast
Le 13/02/2019 à 14:21, ast a écrit : Hello >>> float('Nan') == float('Nan') False Why ? Regards Thank you for answers. If you wonder how I was trapped with it, here is the failing program. r = float('Nan') while r==float('Nan'): inp = input("Enter a number\n") try: r =

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

2019-02-13 Thread Joe Pfeiffer
u...@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 m

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

2019-02-13 Thread Joe Pfeiffer
songbird writes: > Chris Angelico wrote: >> On Thu, Feb 14, 2019 at 7:12 AM Test Bot 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 be >>> equal just as no 2 infinities would be

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

2019-02-13 Thread Chris Angelico
On Thu, Feb 14, 2019 at 11:01 AM songbird wrote: > all such proofs i have ever seen are based upon the > assumptions that there are infinite numbers of such > things like primes. I posted an abbreviated proof of that in a footnote. It's a proof by contradiction. First, assume that there are, in

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

2019-02-13 Thread songbird
Chris Angelico wrote: > On Thu, Feb 14, 2019 at 7:12 AM Test Bot 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 be >> equal just as no 2 infinities would be equal. I believe in a hypo

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

2019-02-13 Thread Chris Angelico
On Thu, Feb 14, 2019 at 9:07 AM Avi Gross wrote: > But that means that normal mathematics is warped. Well yes. Yes, it is. That's why people think "Alice's Adventures in Wonderland" is the result of a drug-induced dream - in actual fact, it's the result of the Dean of Mathematics telling stor

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

2019-02-13 Thread Avi Gross
I think we should realize that Nan and NA and so on are human constructs people Define in programming languages. Some have subdivisions as in not an int as compared to not a float. Python also has an Inf as well as a -Inf that are abstractions and not a real, so to speak. Number. Mathematics

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

2019-02-13 Thread Chris Angelico
‪On Thu, Feb 14, 2019 at 8:24 AM ‫אורי‬‎ wrote:‬ > On Wed, Feb 13, 2019 at 10:20 PM Chris Angelico wrote: >> >> 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

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

2019-02-13 Thread אורי
אורי u...@speedy.net On Wed, Feb 13, 2019 at 10:20 PM Chris Angelico wrote: > On Thu, Feb 14, 2019 at 7:12 AM Test Bot 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 > be > > e

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

2019-02-13 Thread Rob Gaddi
On 2/13/19 12:32 PM, Marko Rauhamaa wrote: "Avi Gross" : A NaN is a bit like a black hole. Anything thrown in disappears and that is about all we know about it. No two black holes are the same even if they seem to have the same mass, spin and charge. All they share is that we don't know what is

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

2019-02-13 Thread Marko Rauhamaa
"Avi Gross" : > A NaN is a bit like a black hole. Anything thrown in disappears and > that is about all we know about it. No two black holes are the same > even if they seem to have the same mass, spin and charge. All they > share is that we don't know what is in them. Then, how do you explain:

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

2019-02-13 Thread Chris Angelico
On Thu, Feb 14, 2019 at 7:12 AM Test Bot 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 be > equal just as no 2 infinities would be equal. I believe in a hypothesis(of > my own creation)

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

2019-02-13 Thread Test Bot
but the concepts may not be. > > -Original Message- > From: Python-list On > Behalf Of Grant Edwards > Sent: Wednesday, February 13, 2019 1:03 PM > To: python-list@python.org > Subject: Re: Why float('Nan') == float('Nan') is False > >

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

2019-02-13 Thread Dan Sommers
On 2/13/19 1:53 PM, Grant Edwards wrote: Floating point is sort of the quantum mechanics of computer science. At first glance, it seems sort of weird. But after you work with it a while, it gets even worse. Yep! :-) -- https://mail.python.org/mailman/listinfo/python-list

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

2019-02-13 Thread Chris Angelico
On Thu, Feb 14, 2019 at 6:55 AM Grant Edwards wrote: > > On 2019-02-13, Schachner, Joseph wrote: > > > This makes some sense because NAN is Not A Number, so any comparison > > to a number fails. > > Ah, but you now seem to be conflating "comparison fails" with > "comparison has a boolean value of

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

2019-02-13 Thread Chris Angelico
On Thu, Feb 14, 2019 at 6:40 AM Schachner, Joseph wrote: > > Because all comparisons with NAN return false, that's the spec. Apart from !=, because it would be insane (I mean, even more insane than it is) to have nan == nan be false AND nan != nan. IEEE NAN has several purposes, including repres

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

2019-02-13 Thread Grant Edwards
On 2019-02-13, Schachner, Joseph wrote: > This makes some sense because NAN is Not A Number, so any comparison > to a number fails. Ah, but you now seem to be conflating "comparison fails" with "comparison has a boolean value of False". The alternative to (nan == nan) => False is probably not (

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

2019-02-13 Thread Schachner, Joseph
n to a number fails. --- Joseph S. -Original Message- From: ast Sent: Wednesday, February 13, 2019 8:21 AM To: python-list@python.org Subject: Why float('Nan') == float('Nan') is False Hello >>> float('Nan') == float('Nan') False Why ?

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

2019-02-13 Thread Joe Pfeiffer
ast writes: > Hello > float('Nan') == float('Nan') > False > > Why ? > > Regards Others have given the real answer -- IEEE says so, and the people who wrote the standard are smarter than me. All the same, this is my take on the reason for it: NaN is specifically a representation for "this

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

2019-02-13 Thread Avi Gross
at is in them. When variable "a" is a Nan then it is sort of a pointer to a concept. The pointer IS itself but the concepts may not be. -Original Message- From: Python-list On Behalf Of Grant Edwards Sent: Wednesday, February 13, 2019 1:03 PM To: python-list@python.org Subject:

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

2019-02-13 Thread Grant Edwards
On 2019-02-13, ast wrote: > Hello > > >>> float('Nan') == float('Nan') > False If you think that's odd, how about this? >>> n = float('nan') >>> n nan >>> n is n True >>> n == n False >>> > Why ? IEEE says so. -- Grant Edwards grant.b.edwards

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

2019-02-13 Thread Dan Sommers
On 2/13/19 7:21 AM, ast wrote: Hello >>> float('Nan') == float('Nan') False Why ? Because the IEEE-754 Standard demands it, and people smarter than I worked on the IEEE-754 Standard. is a quick starting point for a deeper dive. -- https://mail.python.org/

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

2019-02-13 Thread ast
Hello >>> float('Nan') == float('Nan') False Why ? Regards -- https://mail.python.org/mailman/listinfo/python-list