These represent numbers in the range -2147483648 through 2147483647. When the result of an operation would fall outside this range, the result is normally returned as a long integer (in some cases, the exception OverflowError is raised instead).
Plain integers (also just called integers) are implemented using long in C, which gives them at least 32 bits of precision (sys.maxint is always set to the maximum plain integer value for the current platform; the minimum value is -sys.maxint – 1). Long integers have unlimited precision.
Returns an expression converted into an integer number.
Optional. Can be of string, int, float or long type.
Optional. If used number must be a string.
If the number is floating point, the conversion truncates towards zero. If the argument is outside the integer range, the function returns a long object instead.
If the number is not a number or if the base is given, then the number must be a string or Unicode object representing an integer literal. The default base is 10. The allowed values are 0 and 2-36. Base-2, -8, and -16 literals can be optionally prefixed with 0b/0B, 0o/0O/0, or 0x/0X, as with integer literals in code. Base 0 means to interpret the string exactly as an integer literal, so that the actual base is 2, 8, 10, or 16.
>>>#this example converts octal, hex and binary integers into a decimal integer >>> int(0o10) 8 >>> int(0x10) 16 >>> int(0b10) 2
>>> # this example uses base argument >>> int('0101', 2) 5 >>> int('0101', 8) 65 >>> int('0101', 16) 257 >>> int('0101', 10) 101
>>> int(3.14) 3 >>> int(3.14e10) 31400000000L >>> int(-3.14) -3