arbitrary long integer aritmetics

Erik Max Francis max at alcyone.com
Wed Jul 2 03:14:04 EDT 2003


Leo wrote:

> is there a python module around allow using arbitrary long integers?
> 
> i.e. the result of an integer operation is as long as necessary, so
> that a*b
> never produces an overflow error. (but rather an out of memory error
> ;-) )

Long (arbitrary precision) integers are a _builtin type_ in Python:

>>> 10
10
>>> 10L
10L
>>> type(10L)
<type 'long'>
>>> 2L**64L
18446744073709551616L
>>> 10L**100L
10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000L

-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ The death rate is a constant one hundred per cent.
\__/  Camden Benares




More information about the Python-list mailing list