Numeric types of interest are the Python long and complex types. Python long integers should not be
. Python longs have a capacity that surpasses any C
. You are limited only by the amount of (virtual) memory in your system as far as range is
. If you are familiar with Java, a Python long is similar to numbers of the
Moving forward, ints and longs are in the process of becoming unified into a single integer type. Beginning in version 2.3, overflow errors are no longer reportedthe result is automagically converted to a long. In a future version of Python, the distinction will be seamless because the trailing "L" will no longer be used or required.
Boolean values are a special case of integer. Although represented by the constants
, if put in a numeric context such as addition with other numbers,
is treated as the integer with value 1, and
has a value of 0.
Complex numbers (numbers that involve the square root of -1, so-called "imaginary" numbers) are not supported in many languages and perhaps are implemented only as classes in others.
There is also a
numeric type, decimal, for decimal floating numbers, but it is not a built-in type. You must import the
module to use these types of numbers. They were added to Python (version 2.4) because of a need for more accuracy. For example, the number 1.1 cannot be accurately representing with binary floating point numbers (floats) because it has a repeating fraction in binary. Because of this, numbers like 1.1 look like this as a float:
All numeric types are covered in Chapter 5.