Numeric comparison anomaly
Erik Max Francis
max at alcyone.com
Thu Feb 20 22:26:04 CET 2003
sismex01 at hebmex.com wrote:
> > >>> inf = A()
> > >>> inf > inf
> > True
> > >>> inf == inf
> > False
> > >>>
> This is correct, or wrong?
Depends on your background and motivation for providing an "infinity"
that compares greater than all numbers. It's easy enought to fix by
doing an isinstance test against the infinity class, and then changing
the behavior however you'd like.
Infinity is not really a number, it's a concept of something greater
than all numbers. Among transfinite cardinals, there are numbers which
represent "infinity" that are greater or less than other "infinities."
Really asking whether infinity equals itself should be indeterminate,
rather than false. Whether that should raise an exception or just
return false values depends on the precise motivation for including
infinities in the first place.
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ I am a gentlemen: I live by robbing the poor.
\__/ George Bernard Shaw
Blackgirl International / http://www.blackgirl.org/
The Internet resource for black women.
More information about the Python-list