Staging: this is not the live site, pydocs.org.
Numeric and Mathematical Modules
Construct a new Decimal object.
value can be an integer, string, tuple, or another Decimal object. If
no value is given, return Decimal('0'). The context does not affect
the conversion and is only passed to determine if the InvalidOperation
trap is active. Changed in 3.2, 3.3, 3.6 3.2: The argument to the constructor is now permitted to be a float instance.3.2: Mixed-type comparisons between Decimal instances and other numeric types are now fully supported.3.3: float arguments raise an exception if the FloatOperation trap is set. By default the trap is off.3.6: Underscores are allowed for grouping, as with integral and floating-point literals in code.Members of Decimal a adjusted Return the adjusted exponent (exp + digits - 1) of the number. as_integer_ratio Return a pair of integers whose ratio is exactly equal to the original. as_tuple Return a tuple representation of the number. c canonical Return the canonical encoding of the argument. compare_total Compare two operands using their abstract representation. copy_abs Return the absolute value of the argument. copy_sign Return a copy of *self* with the sign of *other*. e exp Return the value of the (natural) exponential function e**x. f from_float Alternative constructor that only accepts instances of float or int. from_number Alternative constructor that only accepts instances of float, int or Decimal, but not strings or tuples. i is_canonical Return True if the argument is canonical and False otherwise. is_finite Return True if the argument is a finite number, and False otherwise. is_infinite Return True if the argument is infinite, and False otherwise. is_nan Return True if the argument is a (quiet or signaling) NaN, else False. is_normal Return True if the argument is a normal number and False otherwise. is_qnan Return True if the argument is a quiet NaN, and False otherwise. is_signed Return True if the argument has a negative sign and False otherwise. is_snan Return True if the argument is a signaling NaN and False otherwise. is_subnormal Return True if the argument is subnormal, and False otherwise. is_zero Return True if the argument is a zero and False otherwise. l ln Return the natural (base e) logarithm of the operand. log10 Return the base ten logarithm of the operand. logb Return the adjusted exponent of the operand as a Decimal instance. logical_and Applies an 'and' operation between self and other's digits. logical_or Applies an 'or' operation between self and other's digits. logical_xor Applies an 'xor' operation between self and other's digits. m max Maximum of self and other. max_mag As the max() method, but compares the absolute values of the operands. min Minimum of self and other. min_mag As the min() method, but compares the absolute values of the operands. n next_minus Returns the largest representable number smaller than itself. next_plus Returns the smallest representable number larger than itself. next_toward Returns the number closest to self, in the direction towards other. normalize Normalize the number by stripping trailing 0s number_class Return a string describing the class of the operand. q quantize Quantize *self* so its exponent is the same as that of *exp*. r rotate Returns a rotated copy of self's digits, value-of-other times. s same_quantum Test whether self and other have the same exponent or both are NaN. scaleb Return the first operand with the exponent adjusted the second. shift Returns a shifted copy of self's digits, value-of-other times. sqrt Return the square root of the argument to full precision. t to_integral Identical to the to_integral_value() method.
Python docs © Python Software Foundation · Examples CC0 ·
Source on GitHub · Not affiliated with the PSF