Staging: this is not the live site, pydocs.org.
Numeric and Mathematical Modules
Create context.
The context affects almost all operations and controls rounding,
Over/Underflow, raising of exceptions and much more. A new context
can be constructed as follows:
>>> c = Context(prec=28, Emin=-425000000, Emax=425000000,
... rounding=ROUND_HALF_EVEN, capitals=1, clamp=1,
... traps=[InvalidOperation, DivisionByZero, Overflow],
... flags=[])
>>> Members of Context a abs Return the absolute value of x. add Return the sum of x and y. c clamp Either 0 (the default) or 1. compare Compare x and y numerically. compare_total Compare x and y using their abstract representation. copy Return a duplicate of the context. copy_abs Return a copy of x with the sign set to 0. create_decimal Create a new Decimal instance from num, using self as the context. d divide_int Return x divided by y, truncated to an integer. divmod Return quotient and remainder of the division x / y. e Emax Integers specifying the outer limits allowable for exponents. Emin Integers specifying the outer limits allowable for exponents. Etiny Return a value equal to Emin - prec + 1. Etop Return a value equal to Emax - prec + 1. f flags Lists of any signals to be set. fma Return x multiplied by y, plus z. i is_finite Return True if x is finite, False otherwise. is_infinite Return True if x is infinite, False otherwise. is_nan Return True if x is a qNaN or sNaN, False otherwise. is_normal Return True if x is a normal number, False otherwise. is_qnan Return True if x is a quiet NaN, False otherwise. is_signed Return True if x is negative, False otherwise. is_snan Return True if x is a signaling NaN, False otherwise. is_zero Return True if x is a zero, False otherwise. l ln Return the natural (base e) logarithm of x. log10 Return the base 10 logarithm of x. logb Return the exponent of the magnitude of the operand's MSD. logical_and Applies the logical operation 'and' between each operand's digits. logical_or Applies the logical operation 'or' between each operand's digits. logical_xor Applies the logical operation 'xor' between each operand's digits. m max Compare the values numerically and return the maximum. max_mag Compare the values numerically with their sign ignored. min Compare the values numerically and return the minimum. min_mag Compare the values numerically with their sign ignored. minus Minus corresponds to unary prefix minus in Python. n next_minus Return the largest representable number smaller than x. next_plus Return the smallest representable number larger than x. next_toward Return the number closest to x, in the direction towards y. p plus Plus corresponds to the unary prefix plus operator in Python. prec An integer in the range [1, MAX_PREC] that sets the precision for arithmetic operations in the context. q quantize Return a value equal to x (rounded), having the exponent of y. r remainder Return the remainder from integer division. rotate Return a copy of x, rotated by y places. rounding One of the constants listed in the section Rounding Modes. s same_quantum Return True if the two operands have the same exponent. scaleb Return the first operand after adding the second value to its exp. shift Return a copy of x, shifted by y places. sqrt Square root of a non-negative number to context precision. subtract Return the difference between x and y. t to_eng_string Convert a number to a string, using engineering notation. to_sci_string Convert a number to a string using scientific notation. traps Lists of any signals to be set.
Python docs © Python Software Foundation · Examples CC0 ·
Source on GitHub · Not affiliated with the PSF