Python has four types to represent numbers:
int,
long,
float,
and
complex.
Values of int and
long types
represent whole numbers. The int
type holds numbers in the range [-2,147,483,648,
2,147,483,647], while the precision of the
long type is limited only by the
available storage. Starting in version 2.2, Python
will automatically switch to long
type when it is needed to avoid overflow.
The factory functions used to convert other types to integer types are:
int(n_s)If is any kind
of number, or string containing a number, this
function converts it to type n_sint.
int(s, r)
If is a
string representation of a number in base (radix)
s ,
this function converts it to type rint.
For example, int("0f", 16) returns 15;
int("101", 2) returns 5.
long(n_s)
Converts a number or string to type
long.
long(s, r)
Converts a string representing a number in
base s
to type rlong.