Integer Overflow

Ursus Horibilis ursus_horibilis at hotmail.com
Tue Nov 27 19:50:21 CET 2001


"Fernando Pérez" <fperez528 at yahoo.com> wrote in message
news:9u0m3l$447$2 at peabody.colorado.edu...
> Ursus Horibilis wrote:
>
> >>
> >> Use longs:
> >>
> >
> > Okay.  My next project was to do the same thing with 64-bit
> > numbers.  So how do I disable trapping for integer
overflow?
> >
> > (And don't tell me to use very longs ;-)
>
> No. Python longs are not C longs, they are arbitrary length
integers (think
> Mathematica/Maple/etc). They're therefore dog slow, but never
overflow. Very
> handy when you really need them.
>

Thanks very much.  I did not realize that a Python long was not
simply a 64-bit number.  Just pure ignorance on my part.  Is it
legal to mask a long and assign it to an int?  For example:

(a) is an (int), (b) is a (long)

b = 6*sys.maxint

a = b & (0xFFFFFFFF)








More information about the Python-list mailing list