27 Apr
2011
27 Apr
'11
5:01 p.m.
Wiadomość napisana przez Hrvoje Niksic w dniu 2011-04-27, o godz. 11:37:
The other day I was surprised to learn this:
nan = float('nan') nan == nan False [nan] == [nan] True # also True in tuples, dicts, etc.
# also:
l = [nan] nan in l True l.index(nan) 0 l[0] == nan False
This surprises me as well. I guess this is all related to the fact that:
nan is nan True
Have a look at this as well:
inf = float('inf') inf == inf True [inf] == [inf] True l = [inf] inf in l True l.index(inf) 0 l[0] == inf True
# Or even:
inf+1 == inf-1 True
For the infinity part, I believe this is related to the funky IEEE 754 standard. I found some discussion about this here: http://compilers.iecc.com/comparch/article/98-07-134 -- Best regards, Łukasz Langa