Upper limit?!

Warren 'The Howdy Man' Ockrassa warren at nightwares.com
Tue Sep 7 16:38:16 EDT 1999


David Oppenheimer wrote:

> I was playing around with the command line and discovered that when I
> enter 2 to the 30th power, I get a number back...when I enter 2 to the
> 31st power I get an overflow error.  Is 2 to the 30th power near the
> upper limit for computations?!

There are max integer limits as noted by other posters, and they vary
from architecture to architecture. One can speculate, for instance, on
what the 128-bit Mac G4 can handle...

But back to the real world. If you explicitly declare your math
operations as floats you can often bypass this limitation:

  >>> import sys
  >>> print sys.maxint
  2147483647
  >>> 2147483647 * 2.0
  4294967294.0
  >>> 2147483647 * 2147483647.0
  4.61168601413e+018

An old trick I learned in Director. Nice to see it here too. :)

--
    warren ockrassa | nightwares | mailto:warren at nightwares.com
                    http://www.nightwares.com/




More information about the Python-list mailing list