checking if a number is int
Johannes Gijsbers
taradino at softhome.net
Sun Apr 7 05:29:45 EDT 2002
Dan Bishop wrote:
> As it shouldn't. In CPython 2.2, math.sqrt(1e100) is 7 629 769 841
> 091 887 003 294 964 970 946 560 higher than its actual value. With an
> absolute error this high, who cares about whether there's a fractional
> part?
>
I'm not sure if anyone would care, but it's quite easy to change the
function to also accept large numbers:
>>> import math
>>> def isWhole(number):
... return long(number) == number
...
>>> isWhole(math.sqrt(1e100))
1
Johannes Gijsbers
--
talk to me..talk to my machine
talk to me
talk to me
More information about the Python-list
mailing list