< BACKMake Note | BookmarkCONTINUE >
156135250194107072078175030179198180024228156016206217188240240204173121140153174186079071

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:

int 0101 84 -237 0x80 017 -680 -0X92  
long 29979062458L -84140l 0xDECADEDEADBEEFBADFEEDDEAL
float 3.14159   4.2E-10   -90. 6.022e23 -1.609E-19
complex 6.23+1.5j   -1.23-875J 0+1j 9.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 to numbers of the BigInteger class type.

Complex numbers (numbers which 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.

All numeric types are covered in Chapter 5.


Last updated on 9/14/2001
Core Python Programming, © 2002 Prentice Hall PTR

< BACKMake Note | BookmarkCONTINUE >

© 2002, O'Reilly & Associates, Inc.