[Tutor] why?

Kent Johnson kent37 at tds.net
Thu May 29 14:27:31 CEST 2008


On Thu, May 29, 2008 at 6:15 AM, Kent Johnson <kent37 at tds.net> wrote:

>  if int(round(cubed_root)) ** 3 == n
> so the cube is done with integer arithmetic instead of floating point.

Compare:
In [1]: 550919 ** 3
Out[1]: 167210386801801559L

In [2]: 550919.0 ** 3
Out[2]: 1.6721038680180157e+017

The cubes you are working with are too large to be represented
accurately with floating point numbers.

Kent


More information about the Tutor mailing list