Next / Previous / Contents / TCC Help System / NM Tech homepage

6.1. Type int: Integers

Python values of type int represent integers, that is, whole numbers in the range [-231, 231-1], roughly plus or minus two billion.

You can represent a value in octal (base 8) by preceding it with a zero. Similarly, use a leading “0x” to represent a value in hexadecimal (base 16). Examples in conversational mode:

>>> 999+1
1000
>>> 077
63
>>> 0xff
255

To convert other numbers or character strings to type int, see Section 13.16, “int(): Convert to int type”.

If you perform operations on int values that result in numbers that are too large, Python automatically converts them to long type; see Section 6.2, “Type long: Extended-precision integers”.