Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Module « decimal » Python 3.11.3

Classe « Context »

Informations générales

Héritage

builtins.object
    Context

Définition

class Context(builtins.object):

help(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=[])
    >>>


Constructeur(s)

Signature du constructeur Description
__new__(*args, **kwargs) Create and return a new object. See help(type) for accurate signature. [extrait de __new__.__doc__]
__init__(self, /, *args, **kwargs) Initialize self. See help(type(self)) for accurate signature. [extrait de __init__.__doc__]

Liste des attributs statiques

Nom de l'attribut Valeur
capitals<attribute 'capitals' of 'decimal.Context' objects>
clamp<attribute 'clamp' of 'decimal.Context' objects>
Emax<attribute 'Emax' of 'decimal.Context' objects>
Emin<attribute 'Emin' of 'decimal.Context' objects>
prec<attribute 'prec' of 'decimal.Context' objects>
rounding<attribute 'rounding' of 'decimal.Context' objects>

Liste des opérateurs

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
__copy__
__delattr__(self, name) Implement delattr(self, name). [extrait de __delattr__.__doc__]
__getattribute__(self, name) Return getattr(self, name). [extrait de __getattribute__.__doc__]
__reduce__
__repr__(self) Return repr(self). [extrait de __repr__.__doc__]
__setattr__(self, name, value) Implement setattr(self, name, value). [extrait de __setattr__.__doc__]
abs(self, x) Return the absolute value of x. [extrait de abs.__doc__]
add(self, x, y) Return the sum of x and y. [extrait de add.__doc__]
canonical(self, x) Return a new instance of x. [extrait de canonical.__doc__]
clear_flags(self) Reset all flags to False. [extrait de clear_flags.__doc__]
clear_traps(self) Set all traps to False. [extrait de clear_traps.__doc__]
compare(self, x, y) Compare x and y numerically. [extrait de compare.__doc__]
compare_signal(self, x, y) Compare x and y numerically. All NaNs signal. [extrait de compare_signal.__doc__]
compare_total(self, x, y) Compare x and y using their abstract representation. [extrait de compare_total.__doc__]
compare_total_mag(self, x, y) Compare x and y using their abstract representation, ignoring sign. [extrait de compare_total_mag.__doc__]
copy(self) Return a duplicate of the context with all flags cleared. [extrait de copy.__doc__]
copy_abs(self, x) Return a copy of x with the sign set to 0. [extrait de copy_abs.__doc__]
copy_decimal(self, x) Return a copy of Decimal x. [extrait de copy_decimal.__doc__]
copy_negate(self, x) Return a copy of x with the sign inverted. [extrait de copy_negate.__doc__]
copy_sign(self, x, y) Copy the sign from y to x. [extrait de copy_sign.__doc__]
create_decimal(self, num='0') Create a new Decimal instance from num, using self as the context. Unlike the [extrait de create_decimal.__doc__]
create_decimal_from_float(self, f) Create a new Decimal instance from float f. Unlike the Decimal.from_float() [extrait de create_decimal_from_float.__doc__]
divide(self, x, y) Return x divided by y. [extrait de divide.__doc__]
divide_int(self, x, y) Return x divided by y, truncated to an integer. [extrait de divide_int.__doc__]
divmod(self, x, y) Return quotient and remainder of the division x / y. [extrait de divmod.__doc__]
Etiny(self) Return a value equal to Emin - prec + 1, which is the minimum exponent value [extrait de Etiny.__doc__]
Etop(self) Return a value equal to Emax - prec + 1. This is the maximum exponent [extrait de Etop.__doc__]
exp(self, x) Return e ** x. [extrait de exp.__doc__]
fma(self, x, y, z) Return x multiplied by y, plus z. [extrait de fma.__doc__]
is_canonical(self, x) Return True if x is canonical, False otherwise. [extrait de is_canonical.__doc__]
is_finite(self, x) Return True if x is finite, False otherwise. [extrait de is_finite.__doc__]
is_infinite(self, x) Return True if x is infinite, False otherwise. [extrait de is_infinite.__doc__]
is_nan(self, x) Return True if x is a qNaN or sNaN, False otherwise. [extrait de is_nan.__doc__]
is_normal(self, x) Return True if x is a normal number, False otherwise. [extrait de is_normal.__doc__]
is_qnan(self, x) Return True if x is a quiet NaN, False otherwise. [extrait de is_qnan.__doc__]
is_signed(self, x) Return True if x is negative, False otherwise. [extrait de is_signed.__doc__]
is_snan(self, x) Return True if x is a signaling NaN, False otherwise. [extrait de is_snan.__doc__]
is_subnormal(self, x) Return True if x is subnormal, False otherwise. [extrait de is_subnormal.__doc__]
is_zero(self, x) Return True if x is a zero, False otherwise. [extrait de is_zero.__doc__]
ln(self, x) Return the natural (base e) logarithm of x. [extrait de ln.__doc__]
log10(self, x) Return the base 10 logarithm of x. [extrait de log10.__doc__]
logb(self, x) Return the exponent of the magnitude of the operand's MSD. [extrait de logb.__doc__]
logical_and(self, x, y) Digit-wise and of x and y. [extrait de logical_and.__doc__]
logical_invert(self, x) Invert all digits of x. [extrait de logical_invert.__doc__]
logical_or(self, x, y) Digit-wise or of x and y. [extrait de logical_or.__doc__]
logical_xor(self, x, y) Digit-wise xor of x and y. [extrait de logical_xor.__doc__]
max(self, x, y) Compare the values numerically and return the maximum. [extrait de max.__doc__]
max_mag(self, x, y) Compare the values numerically with their sign ignored. [extrait de max_mag.__doc__]
min(self, x, y) Compare the values numerically and return the minimum. [extrait de min.__doc__]
min_mag(self, x, y) Compare the values numerically with their sign ignored. [extrait de min_mag.__doc__]
minus(self, x) Minus corresponds to the unary prefix minus operator in Python, but applies [extrait de minus.__doc__]
multiply(self, x, y) Return the product of x and y. [extrait de multiply.__doc__]
next_minus(self, x) Return the largest representable number smaller than x. [extrait de next_minus.__doc__]
next_plus(self, x) Return the smallest representable number larger than x. [extrait de next_plus.__doc__]
next_toward(self, x, y) Return the number closest to x, in the direction towards y. [extrait de next_toward.__doc__]
normalize(self, x) Reduce x to its simplest form. Alias for reduce(x). [extrait de normalize.__doc__]
number_class(self, x) Return an indication of the class of x. [extrait de number_class.__doc__]
plus(self, x) Plus corresponds to the unary prefix plus operator in Python, but applies [extrait de plus.__doc__]
power(self, /, a, b, modulo=None) Compute a**b. If 'a' is negative, then 'b' must be integral. The result [extrait de power.__doc__]
quantize(self, x, y) Return a value equal to x (rounded), having the exponent of y. [extrait de quantize.__doc__]
radix(self) Return 10. [extrait de radix.__doc__]
remainder(self, x, y) Return the remainder from integer division. The sign of the result, [extrait de remainder.__doc__]
remainder_near(self, x, y) Return x - y * n, where n is the integer nearest the exact value of x / y [extrait de remainder_near.__doc__]
rotate(self, x, y) Return a copy of x, rotated by y places. [extrait de rotate.__doc__]
same_quantum(self, x, y) Return True if the two operands have the same exponent. [extrait de same_quantum.__doc__]
scaleb(self, x, y) Return the first operand after adding the second value to its exp. [extrait de scaleb.__doc__]
shift(self, x, y) Return a copy of x, shifted by y places. [extrait de shift.__doc__]
sqrt(self, x) Square root of a non-negative number to context precision. [extrait de sqrt.__doc__]
subtract(self, x, y) Return the difference between x and y. [extrait de subtract.__doc__]
to_eng_string(self, x) Convert a number to a string, using engineering notation. [extrait de to_eng_string.__doc__]
to_integral(self, x) Identical to to_integral_value(x). [extrait de to_integral.__doc__]
to_integral_exact(self, x) Round to an integer. Signal if the result is rounded or inexact. [extrait de to_integral_exact.__doc__]
to_integral_value(self, x) Round to an integer. [extrait de to_integral_value.__doc__]
to_sci_string(self, x) Convert a number to a string using scientific notation. [extrait de to_sci_string.__doc__]

Méthodes héritées de la classe object

__dir__, __format__, __getstate__, __hash__, __init_subclass__, __reduce_ex__, __sizeof__, __str__, __subclasshook__