Python has two types of integers. Plain integers are the generic vanilla (32-bit) integers recognized on most systems today. Python also has a long integer size; however, these far exceed the size provided by C longs. We will take a look at both types of Python integers, followed by a description of operators and built-in functions applicable only to Python integer types.

(Plain) Integers

Python’s “plain” integers are the universal numeric type. Most machines (32-bit) running Python will provide a range of -231 to 231-1, that is -2,147,483,648 to 2,147,483,647. ere are some examples of Python integers:
0101 84 -237 0x80 017 -680 -0X92
Python integers are implemented as (signed) longs in C. Integers are normally represented in base 10 decimal format, but they can also be specified in base eight or base sixteen representation. Octal values have a “0” prefix, and hexadecimal values have either “0x” or “0X” prefixes.

Long Integers

The first thing we need to say about Python long integers is to not get them confused with
long integers in C or other compiled languages—these values are typically restricted to 32- or 64-bit sizes, whereas Python long integers are limited only by the amount of (virtual) memory in your machine. In other words, they can be very L-O-N-G longs.
Long integers are a superset of integers and are useful when the range of plain integers exceeds those of your application, meaning less than -231 or greater than 231-1. Use of long integers is denoted by an upper- or lowercase (L) or (l), appended to the integer’s numeric value. Values can be expressed in decimal, octal, or hexadecimal. The following are examples of long integers:
16384L -0x4E8L 017L -2147483648l 052144364L
299792458l 0xDECADEDEADBEEFBADFEEDDEAL – 5432101234L
Although Python supports a case-insensitive “L” to denote long integers, we recommend that you use only the uppercase “L” to avoid confusion with the number “one” ( 1 ). Python will display only long integers with a capital “L.”

>>> aLong = 99999999l
>>> aLong

You may also like...