arbitrary long integer aritmetics

Andrew Bennetts andrew-pythonlist at puzzling.org
Wed Jul 2 06:12:13 EDT 2003


On Wed, Jul 02, 2003 at 12:05:29PM +0200, Fredrik Lundh wrote:
> "Leo" wrote:
> 
> > i.e. the result of an integer operation is as long as necessary, so that a*b
> > never produces an overflow error.
> 
> what's an overflow error? ;-)
> 
> $ python
> Python 2.2
> >>> import sys
> >>> sys.maxint
> 2147483647
> >>> 2147483647 * 2147483647 * 2147483647
> 4611686014132420609L
> 
> (note the trailing L).

I also note that your Python 2.2 does arithmetic differently to mine:

$ python2.2
Python 2.2.2 [etc etc]
>>> 2147483647 * 2147483647 * 2147483647
9903520300447984150353281023L

-Andrew.






More information about the Python-list mailing list