[David Mertz <me...@gnosis.cx>]
> ...
> I can see no sane reason why anyone would ever call float.is_integer()
> actually. That should always be spelled math.isclose(x, int(x)) because
> IEEE-754. Attractive nuisance is probably too generous, I'd simply call the
> method a bug.

Sometimes it's necessary to know, and especially when _implementing_
754-conforming functions.  For example, what negative infinity raised
to a power needs to return depends on whether the power is an integer
(specifically on whether it's an odd integer):

>>> (-math.inf) ** random.random()
inf
>>> (-math.inf) ** random.random()
inf
>>> (-math.inf) ** random.random()
inf
>>> (-math.inf) ** 3.1
inf
>>> (-math.inf) ** 3.0 # NOTE THIS ONE
-inf
>>> (-math.inf) ** 2.9
inf

But, ya, for most people most of the time I agree is_integer() is an
attractive nuisance.  People implementing math functions are famous
for cheerfully enduring any amount of pain needed to get the job done
;-)
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to