2.6. Numbers

Python supports four different numerical types:

  • int (signed integers)

  • long (long integers [can also be represented in octal and hexadecimal])

  • float (floating point real values)

  • complex (complex numbers)

Here are some examples:

int010184-2370x80017-680-0X92 
long29979062458L-84140l0xDECADEDEADBEEFBADFEEDDEAL
float3.14159 4.2E-10 -90.6.022e23-1.609E-19
complex6.23+1.5j -1.23-875J0+1j9.80665-8.31441J-.0224+0j

Numeric types of interest are the Python long and complex types. Python long integers should not be confused with C long s. Python longs have a capacity that surpasses any C long. You are limited only by the amount of (virtual) memory in your system as far as range is concerned. If you are familiar with Java, a Python long is similar ...

Get Core Python Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.