How to convert

Felipe Almeida Lessa felipe.lessa at gmail.com
Sat Mar 18 08:40:48 EST 2006


Em Sáb, 2006-03-18 às 10:38 -0300, Felipe Almeida Lessa escreveu:
> Em Sáb, 2006-03-18 às 05:12 -0800, Lad escreveu:
> > How can I covert in Python  a variable of a long type to variable of
> > Integer type?
> 
> You can do "int(variable)", but it can't be always done (for example,
> when variable > MAX_INT):

A more concrete example:
>>> int(2**31)
2147483648L
>>> int(2**31-1)
2147483647
>>> int(-2**31)
-2147483648
>>> int(-2**31-1)
-2147483649L





More information about the Python-list mailing list