Next / Previous / Contents / Shipman's homepage

7.2. Type long: Extended-precision integers

Values of long type represent whole numbers, but they may have many more than the nine or ten digits allowed by int type. In practice, the number of digits in a long value is limited only by processor memory size.

To write a long-type constant, use the same syntax as for int-type constants, but place a letter L immediately after the last digit. Also, if an operation on int values results in a number too large to represent as an int, Python will automatically converted it to type long.

>>> 100 * 100
>>> 100L * 100L
>>> 1000000000*1000000000
>>> 0xffffL

To convert a value of a different numeric type or a string of characters to a long value, see Section 20.24, “long(): Convert to long type”.