| Table B.3 represents the operators and (built-in and factory) functions that apply to Python's numeric objects. Table B.3. Operators and Built-in Functions for All Numeric TypesOperator/built-in | Description | int | long | float | complex | Result[a] |
|---|
abs() | Absolute value | • | • | • | • | number[a] | chr() | Character | • | • | | | str | coerce() | Numeric coercion | • | • | • | • | tuple | complex() | Complex factory function | • | • | • | • | complex | divmod() | Division/modulo | • | • | • | • | tuple | float() | Float factory function | • | • | • | • | float | hex() | Hexadecimal string | • | • | | | str | int() | Int factory function | • | • | • | • | int | long() | Long factory function | • | • | • | • | long | oct() | Octal string | • | • | | | str | ord() | Ordinal | (string) | int | pow() | Exponentiation | • | • | • | • | number | round() | Float rounding | | | • | | float | **[b] | Exponentiation | • | • | • | • | number | +[c] | No change | • | • | • | • | number | -[c] | Negation | • | • | • | • | number | ~[c] | Bit inversion | • | • | | | int/long | **[b] | Exponentiation | • | • | • | • | number | * | Multiplication | • | • | • | • | number | / | Classic or true division | • | • | • | • | number | // | Floor division | • | • | • | • | number | % | Modulo/remainder | • | • | • | • | number | + | Addition | • | • | • | • | number | - | Subtraction | • | • | • | • | number | << | Bit left shift | • | • | | | int/long | >> | Bit right shift | • | • | | | int/long | & | Bitwise AND | • | • | | | int/long | ^ | Bitwise XOR | • | • | | | int/long | | | Bitwise OR | • | • | | | int/long |
[a] A result of "number" indicates any of the numeric types, perhaps the same as the operands. [b] ** has a unique relationship with unary operators; see Section 5.5.3 and Table 5.2. [c] Unary operator. |