Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes | Properties | Private Member Functions | Private Attributes | Static Private Attributes
decimal.Context Class Reference
Inheritance diagram for decimal.Context:
Inheritance graph
[legend]
Collaboration diagram for decimal.Context:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __repr__
def clear_flags
def copy
def Etiny
def Etop
def create_decimal
def create_decimal_from_float
def abs
def add
def canonical
def compare
def compare_signal
def compare_total
def compare_total_mag
def copy_abs
def copy_decimal
def copy_negate
def copy_sign
def divide
def divide_int
def divmod
def exp
def fma
def is_canonical
def is_finite
def is_infinite
def is_nan
def is_normal
def is_qnan
def is_signed
def is_snan
def is_subnormal
def is_zero
def ln
def log10
def logb
def logical_and
def logical_invert
def logical_or
def logical_xor
def max
def max_mag
def min
def min_mag
def minus
def multiply
def next_minus
def next_plus
def next_toward
def normalize
def number_class
def plus
def power
def quantize
def radix
def remainder
def remainder_near
def rotate
def same_quantum
def scaleb
def shift
def sqrt
def subtract
def to_eng_string
def to_sci_string
def to_integral_exact
def to_integral_value

Public Attributes

 prec
 rounding
 Emin
 Emax
 capitals
 clamp
 traps
 flags
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Static Public Attributes

 to_integral = to_integral_value

Properties

 _clamp = property(_get_clamp, _set_clamp)

Private Member Functions

def _shallow_copy
def _get_clamp
def _set_clamp
def _raise_error
def _ignore_all_flags
def _ignore_flags
def _regard_flags
def _set_rounding
def _apply

Private Attributes

 _ignored_flags

Static Private Attributes

 __copy__ = copy
 __hash__ = None

Detailed Description

Contains the context for a Decimal instance.

Contains:
prec - precision (for use in rounding, division, square roots..)
rounding - rounding type (how you round)
traps - If traps[exception] = 1, then the exception is
                raised when it is caused.  Otherwise, a value is
                substituted in.
flags  - When an exception is caused, flags[exception] is set.
         (Whether or not the trap_enabler is set)
         Should be reset by user of Decimal instance.
Emin -   Minimum exponent
Emax -   Maximum exponent
capitals -      If 1, 1*10^1 is printed as 1E+1.
                If 0, printed as 1e1
clamp -  If 1, change exponents if too high (Default 0)

Definition at line 3794 of file decimal.py.


Constructor & Destructor Documentation

def decimal.Context.__init__ (   self,
  prec = None,
  rounding = None,
  traps = None,
  flags = None,
  Emin = None,
  Emax = None,
  capitals = None,
  clamp = None,
  _ignored_flags = None 
)

Definition at line 3817 of file decimal.py.

03817 
03818                  _ignored_flags=None):
03819         # Set defaults; for everything except flags and _ignored_flags,
03820         # inherit from DefaultContext.
03821         try:
03822             dc = DefaultContext
03823         except NameError:
03824             pass
03825 
03826         self.prec = prec if prec is not None else dc.prec
03827         self.rounding = rounding if rounding is not None else dc.rounding
03828         self.Emin = Emin if Emin is not None else dc.Emin
03829         self.Emax = Emax if Emax is not None else dc.Emax
03830         self.capitals = capitals if capitals is not None else dc.capitals
03831         self.clamp = clamp if clamp is not None else dc.clamp
03832 
03833         if _ignored_flags is None:
03834             self._ignored_flags = []
03835         else:
03836             self._ignored_flags = _ignored_flags
03837 
03838         if traps is None:
03839             self.traps = dc.traps.copy()
03840         elif not isinstance(traps, dict):
03841             self.traps = dict((s, int(s in traps)) for s in _signals)
03842         else:
03843             self.traps = traps
03844 
03845         if flags is None:
03846             self.flags = dict.fromkeys(_signals, 0)
03847         elif not isinstance(flags, dict):
03848             self.flags = dict((s, int(s in flags)) for s in _signals)
03849         else:
03850             self.flags = flags

Here is the caller graph for this function:


Member Function Documentation

def decimal.Context.__repr__ (   self)
Show the current context.

Definition at line 3851 of file decimal.py.

03851 
03852     def __repr__(self):
03853         """Show the current context."""
03854         s = []
03855         s.append('Context(prec=%(prec)d, rounding=%(rounding)s, '
03856                  'Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d, '
03857                  'clamp=%(clamp)d'
03858                  % vars(self))
03859         names = [f.__name__ for f, v in self.flags.items() if v]
03860         s.append('flags=[' + ', '.join(names) + ']')
03861         names = [t.__name__ for t, v in self.traps.items() if v]
03862         s.append('traps=[' + ', '.join(names) + ']')
03863         return ', '.join(s) + ')'

def decimal.Context._apply (   self,
  a 
) [private]

Definition at line 4053 of file decimal.py.

04053 
04054     def _apply(self, a):
04055         return str(a._fix(self))

def decimal.Context._get_clamp (   self) [private]

Definition at line 3886 of file decimal.py.

03886 
03887     def _get_clamp(self):
03888         "_clamp mirrors the clamp attribute.  Its use is deprecated."
03889         import warnings
03890         warnings.warn('Use of the _clamp attribute is deprecated. '
03891                       'Please use clamp instead.',
03892                       DeprecationWarning)
03893         return self.clamp

Here is the call graph for this function:

def decimal.Context._ignore_all_flags (   self) [private]
Ignore all flags, if they are raised

Definition at line 3928 of file decimal.py.

03928 
03929     def _ignore_all_flags(self):
03930         """Ignore all flags, if they are raised"""
03931         return self._ignore_flags(*_signals)

Here is the call graph for this function:

def decimal.Context._ignore_flags (   self,
  flags 
) [private]
Ignore the flags, if they are raised

Definition at line 3932 of file decimal.py.

03932 
03933     def _ignore_flags(self, *flags):
03934         """Ignore the flags, if they are raised"""
03935         # Do not mutate-- This way, copies of a context leave the original
03936         # alone.
03937         self._ignored_flags = (self._ignored_flags + list(flags))
03938         return list(flags)

Here is the caller graph for this function:

def decimal.Context._raise_error (   self,
  condition,
  explanation = None,
  args 
) [private]
Handles an error

If the flag is in _ignored_flags, returns the default response.
Otherwise, it sets the flag, then, if the corresponding
trap_enabler is set, it reraises the exception.  Otherwise, it returns
the default value after setting the flag.

Definition at line 3906 of file decimal.py.

03906 
03907     def _raise_error(self, condition, explanation = None, *args):
03908         """Handles an error
03909 
03910         If the flag is in _ignored_flags, returns the default response.
03911         Otherwise, it sets the flag, then, if the corresponding
03912         trap_enabler is set, it reraises the exception.  Otherwise, it returns
03913         the default value after setting the flag.
03914         """
03915         error = _condition_map.get(condition, condition)
03916         if error in self._ignored_flags:
03917             # Don't touch the flag
03918             return error().handle(self, *args)
03919 
03920         self.flags[error] = 1
03921         if not self.traps[error]:
03922             # The errors define how to handle themselves.
03923             return condition().handle(self, *args)
03924 
03925         # Errors should only be risked on copies of the context
03926         # self._ignored_flags = []
03927         raise error(explanation)

Here is the caller graph for this function:

def decimal.Context._regard_flags (   self,
  flags 
) [private]
Stop ignoring the flags, if they are raised

Definition at line 3939 of file decimal.py.

03939 
03940     def _regard_flags(self, *flags):
03941         """Stop ignoring the flags, if they are raised"""
03942         if flags and isinstance(flags[0], (tuple,list)):
03943             flags = flags[0]
03944         for flag in flags:
03945             self._ignored_flags.remove(flag)

def decimal.Context._set_clamp (   self,
  clamp 
) [private]

Definition at line 3894 of file decimal.py.

03894 
03895     def _set_clamp(self, clamp):
03896         "_clamp mirrors the clamp attribute.  Its use is deprecated."
03897         import warnings
03898         warnings.warn('Use of the _clamp attribute is deprecated. '
03899                       'Please use clamp instead.',
03900                       DeprecationWarning)
03901         self.clamp = clamp

Here is the call graph for this function:

def decimal.Context._set_rounding (   self,
  type 
) [private]
Sets the rounding type.

Sets the rounding type, and returns the current (previous)
rounding type.  Often used like:

context = context.copy()
# so you don't change the calling context
# if an error occurs in the middle.
rounding = context._set_rounding(ROUND_UP)
val = self.__sub__(other, context=context)
context._set_rounding(rounding)

This will make it round up for that operation.

Definition at line 3957 of file decimal.py.

03957 
03958     def _set_rounding(self, type):
03959         """Sets the rounding type.
03960 
03961         Sets the rounding type, and returns the current (previous)
03962         rounding type.  Often used like:
03963 
03964         context = context.copy()
03965         # so you don't change the calling context
03966         # if an error occurs in the middle.
03967         rounding = context._set_rounding(ROUND_UP)
03968         val = self.__sub__(other, context=context)
03969         context._set_rounding(rounding)
03970 
03971         This will make it round up for that operation.
03972         """
03973         rounding = self.rounding
03974         self.rounding= type
03975         return rounding

def decimal.Context._shallow_copy (   self) [private]
Returns a shallow copy from self.

Definition at line 3869 of file decimal.py.

03869 
03870     def _shallow_copy(self):
03871         """Returns a shallow copy from self."""
03872         nc = Context(self.prec, self.rounding, self.traps,
03873                      self.flags, self.Emin, self.Emax,
03874                      self.capitals, self.clamp, self._ignored_flags)
03875         return nc

def decimal.Context.abs (   self,
  a 
)
Returns the absolute value of the operand.

If the operand is negative, the result is the same as using the minus
operation on the operand.  Otherwise, the result is the same as using
the plus operation on the operand.

>>> ExtendedContext.abs(Decimal('2.1'))
Decimal('2.1')
>>> ExtendedContext.abs(Decimal('-100'))
Decimal('100')
>>> ExtendedContext.abs(Decimal('101.5'))
Decimal('101.5')
>>> ExtendedContext.abs(Decimal('-101.5'))
Decimal('101.5')
>>> ExtendedContext.abs(-1)
Decimal('1')

Definition at line 4011 of file decimal.py.

04011 
04012     def abs(self, a):
04013         """Returns the absolute value of the operand.
04014 
04015         If the operand is negative, the result is the same as using the minus
04016         operation on the operand.  Otherwise, the result is the same as using
04017         the plus operation on the operand.
04018 
04019         >>> ExtendedContext.abs(Decimal('2.1'))
04020         Decimal('2.1')
04021         >>> ExtendedContext.abs(Decimal('-100'))
04022         Decimal('100')
04023         >>> ExtendedContext.abs(Decimal('101.5'))
04024         Decimal('101.5')
04025         >>> ExtendedContext.abs(Decimal('-101.5'))
04026         Decimal('101.5')
04027         >>> ExtendedContext.abs(-1)
04028         Decimal('1')
04029         """
04030         a = _convert_other(a, raiseit=True)
04031         return a.__abs__(context=self)

Here is the call graph for this function:

def decimal.Context.add (   self,
  a,
  b 
)
Return the sum of the two operands.

>>> ExtendedContext.add(Decimal('12'), Decimal('7.00'))
Decimal('19.00')
>>> ExtendedContext.add(Decimal('1E+2'), Decimal('1.01E+4'))
Decimal('1.02E+4')
>>> ExtendedContext.add(1, Decimal(2))
Decimal('3')
>>> ExtendedContext.add(Decimal(8), 5)
Decimal('13')
>>> ExtendedContext.add(5, 5)
Decimal('10')

Definition at line 4032 of file decimal.py.

04032 
04033     def add(self, a, b):
04034         """Return the sum of the two operands.
04035 
04036         >>> ExtendedContext.add(Decimal('12'), Decimal('7.00'))
04037         Decimal('19.00')
04038         >>> ExtendedContext.add(Decimal('1E+2'), Decimal('1.01E+4'))
04039         Decimal('1.02E+4')
04040         >>> ExtendedContext.add(1, Decimal(2))
04041         Decimal('3')
04042         >>> ExtendedContext.add(Decimal(8), 5)
04043         Decimal('13')
04044         >>> ExtendedContext.add(5, 5)
04045         Decimal('10')
04046         """
04047         a = _convert_other(a, raiseit=True)
04048         r = a.__add__(b, context=self)
04049         if r is NotImplemented:
04050             raise TypeError("Unable to convert %s to Decimal" % b)
04051         else:
04052             return r

Here is the call graph for this function:

Here is the caller graph for this function:

def decimal.Context.canonical (   self,
  a 
)
Returns the same Decimal object.

As we do not have different encodings for the same number, the
received object already is in its canonical form.

>>> ExtendedContext.canonical(Decimal('2.50'))
Decimal('2.50')

Definition at line 4056 of file decimal.py.

04056 
04057     def canonical(self, a):
04058         """Returns the same Decimal object.
04059 
04060         As we do not have different encodings for the same number, the
04061         received object already is in its canonical form.
04062 
04063         >>> ExtendedContext.canonical(Decimal('2.50'))
04064         Decimal('2.50')
04065         """
04066         return a.canonical(context=self)

Reset all flags to zero

Definition at line 3864 of file decimal.py.

03864 
03865     def clear_flags(self):
03866         """Reset all flags to zero"""
03867         for flag in self.flags:
03868             self.flags[flag] = 0

def decimal.Context.compare (   self,
  a,
  b 
)
Compares values numerically.

If the signs of the operands differ, a value representing each operand
('-1' if the operand is less than zero, '0' if the operand is zero or
negative zero, or '1' if the operand is greater than zero) is used in
place of that operand for the comparison instead of the actual
operand.

The comparison is then effected by subtracting the second operand from
the first and then returning a value according to the result of the
subtraction: '-1' if the result is less than zero, '0' if the result is
zero or negative zero, or '1' if the result is greater than zero.

>>> ExtendedContext.compare(Decimal('2.1'), Decimal('3'))
Decimal('-1')
>>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.1'))
Decimal('0')
>>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.10'))
Decimal('0')
>>> ExtendedContext.compare(Decimal('3'), Decimal('2.1'))
Decimal('1')
>>> ExtendedContext.compare(Decimal('2.1'), Decimal('-3'))
Decimal('1')
>>> ExtendedContext.compare(Decimal('-3'), Decimal('2.1'))
Decimal('-1')
>>> ExtendedContext.compare(1, 2)
Decimal('-1')
>>> ExtendedContext.compare(Decimal(1), 2)
Decimal('-1')
>>> ExtendedContext.compare(1, Decimal(2))
Decimal('-1')

Definition at line 4067 of file decimal.py.

04067 
04068     def compare(self, a, b):
04069         """Compares values numerically.
04070 
04071         If the signs of the operands differ, a value representing each operand
04072         ('-1' if the operand is less than zero, '0' if the operand is zero or
04073         negative zero, or '1' if the operand is greater than zero) is used in
04074         place of that operand for the comparison instead of the actual
04075         operand.
04076 
04077         The comparison is then effected by subtracting the second operand from
04078         the first and then returning a value according to the result of the
04079         subtraction: '-1' if the result is less than zero, '0' if the result is
04080         zero or negative zero, or '1' if the result is greater than zero.
04081 
04082         >>> ExtendedContext.compare(Decimal('2.1'), Decimal('3'))
04083         Decimal('-1')
04084         >>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.1'))
04085         Decimal('0')
04086         >>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.10'))
04087         Decimal('0')
04088         >>> ExtendedContext.compare(Decimal('3'), Decimal('2.1'))
04089         Decimal('1')
04090         >>> ExtendedContext.compare(Decimal('2.1'), Decimal('-3'))
04091         Decimal('1')
04092         >>> ExtendedContext.compare(Decimal('-3'), Decimal('2.1'))
04093         Decimal('-1')
04094         >>> ExtendedContext.compare(1, 2)
04095         Decimal('-1')
04096         >>> ExtendedContext.compare(Decimal(1), 2)
04097         Decimal('-1')
04098         >>> ExtendedContext.compare(1, Decimal(2))
04099         Decimal('-1')
04100         """
04101         a = _convert_other(a, raiseit=True)
04102         return a.compare(b, context=self)

Here is the call graph for this function:

def decimal.Context.compare_signal (   self,
  a,
  b 
)
Compares the values of the two operands numerically.

It's pretty much like compare(), but all NaNs signal, with signaling
NaNs taking precedence over quiet NaNs.

>>> c = ExtendedContext
>>> c.compare_signal(Decimal('2.1'), Decimal('3'))
Decimal('-1')
>>> c.compare_signal(Decimal('2.1'), Decimal('2.1'))
Decimal('0')
>>> c.flags[InvalidOperation] = 0
>>> print(c.flags[InvalidOperation])
0
>>> c.compare_signal(Decimal('NaN'), Decimal('2.1'))
Decimal('NaN')
>>> print(c.flags[InvalidOperation])
1
>>> c.flags[InvalidOperation] = 0
>>> print(c.flags[InvalidOperation])
0
>>> c.compare_signal(Decimal('sNaN'), Decimal('2.1'))
Decimal('NaN')
>>> print(c.flags[InvalidOperation])
1
>>> c.compare_signal(-1, 2)
Decimal('-1')
>>> c.compare_signal(Decimal(-1), 2)
Decimal('-1')
>>> c.compare_signal(-1, Decimal(2))
Decimal('-1')

Definition at line 4103 of file decimal.py.

04103 
04104     def compare_signal(self, a, b):
04105         """Compares the values of the two operands numerically.
04106 
04107         It's pretty much like compare(), but all NaNs signal, with signaling
04108         NaNs taking precedence over quiet NaNs.
04109 
04110         >>> c = ExtendedContext
04111         >>> c.compare_signal(Decimal('2.1'), Decimal('3'))
04112         Decimal('-1')
04113         >>> c.compare_signal(Decimal('2.1'), Decimal('2.1'))
04114         Decimal('0')
04115         >>> c.flags[InvalidOperation] = 0
04116         >>> print(c.flags[InvalidOperation])
04117         0
04118         >>> c.compare_signal(Decimal('NaN'), Decimal('2.1'))
04119         Decimal('NaN')
04120         >>> print(c.flags[InvalidOperation])
04121         1
04122         >>> c.flags[InvalidOperation] = 0
04123         >>> print(c.flags[InvalidOperation])
04124         0
04125         >>> c.compare_signal(Decimal('sNaN'), Decimal('2.1'))
04126         Decimal('NaN')
04127         >>> print(c.flags[InvalidOperation])
04128         1
04129         >>> c.compare_signal(-1, 2)
04130         Decimal('-1')
04131         >>> c.compare_signal(Decimal(-1), 2)
04132         Decimal('-1')
04133         >>> c.compare_signal(-1, Decimal(2))
04134         Decimal('-1')
04135         """
04136         a = _convert_other(a, raiseit=True)
04137         return a.compare_signal(b, context=self)

Here is the call graph for this function:

def decimal.Context.compare_total (   self,
  a,
  b 
)
Compares two operands using their abstract representation.

This is not like the standard compare, which use their numerical
value. Note that a total ordering is defined for all possible abstract
representations.

>>> ExtendedContext.compare_total(Decimal('12.73'), Decimal('127.9'))
Decimal('-1')
>>> ExtendedContext.compare_total(Decimal('-127'),  Decimal('12'))
Decimal('-1')
>>> ExtendedContext.compare_total(Decimal('12.30'), Decimal('12.3'))
Decimal('-1')
>>> ExtendedContext.compare_total(Decimal('12.30'), Decimal('12.30'))
Decimal('0')
>>> ExtendedContext.compare_total(Decimal('12.3'),  Decimal('12.300'))
Decimal('1')
>>> ExtendedContext.compare_total(Decimal('12.3'),  Decimal('NaN'))
Decimal('-1')
>>> ExtendedContext.compare_total(1, 2)
Decimal('-1')
>>> ExtendedContext.compare_total(Decimal(1), 2)
Decimal('-1')
>>> ExtendedContext.compare_total(1, Decimal(2))
Decimal('-1')

Definition at line 4138 of file decimal.py.

04138 
04139     def compare_total(self, a, b):
04140         """Compares two operands using their abstract representation.
04141 
04142         This is not like the standard compare, which use their numerical
04143         value. Note that a total ordering is defined for all possible abstract
04144         representations.
04145 
04146         >>> ExtendedContext.compare_total(Decimal('12.73'), Decimal('127.9'))
04147         Decimal('-1')
04148         >>> ExtendedContext.compare_total(Decimal('-127'),  Decimal('12'))
04149         Decimal('-1')
04150         >>> ExtendedContext.compare_total(Decimal('12.30'), Decimal('12.3'))
04151         Decimal('-1')
04152         >>> ExtendedContext.compare_total(Decimal('12.30'), Decimal('12.30'))
04153         Decimal('0')
04154         >>> ExtendedContext.compare_total(Decimal('12.3'),  Decimal('12.300'))
04155         Decimal('1')
04156         >>> ExtendedContext.compare_total(Decimal('12.3'),  Decimal('NaN'))
04157         Decimal('-1')
04158         >>> ExtendedContext.compare_total(1, 2)
04159         Decimal('-1')
04160         >>> ExtendedContext.compare_total(Decimal(1), 2)
04161         Decimal('-1')
04162         >>> ExtendedContext.compare_total(1, Decimal(2))
04163         Decimal('-1')
04164         """
04165         a = _convert_other(a, raiseit=True)
04166         return a.compare_total(b)

Here is the call graph for this function:

def decimal.Context.compare_total_mag (   self,
  a,
  b 
)
Compares two operands using their abstract representation ignoring sign.

Like compare_total, but with operand's sign ignored and assumed to be 0.

Definition at line 4167 of file decimal.py.

04167 
04168     def compare_total_mag(self, a, b):
04169         """Compares two operands using their abstract representation ignoring sign.
04170 
04171         Like compare_total, but with operand's sign ignored and assumed to be 0.
04172         """
04173         a = _convert_other(a, raiseit=True)
04174         return a.compare_total_mag(b)

Here is the call graph for this function:

def decimal.Context.copy (   self)
Returns a deep copy from self.

Definition at line 3876 of file decimal.py.

03876 
03877     def copy(self):
03878         """Returns a deep copy from self."""
03879         nc = Context(self.prec, self.rounding, self.traps.copy(),
03880                      self.flags.copy(), self.Emin, self.Emax,
03881                      self.capitals, self.clamp, self._ignored_flags)
        return nc
def decimal.Context.copy_abs (   self,
  a 
)
Returns a copy of the operand with the sign set to 0.

>>> ExtendedContext.copy_abs(Decimal('2.1'))
Decimal('2.1')
>>> ExtendedContext.copy_abs(Decimal('-100'))
Decimal('100')
>>> ExtendedContext.copy_abs(-1)
Decimal('1')

Definition at line 4175 of file decimal.py.

04175 
04176     def copy_abs(self, a):
04177         """Returns a copy of the operand with the sign set to 0.
04178 
04179         >>> ExtendedContext.copy_abs(Decimal('2.1'))
04180         Decimal('2.1')
04181         >>> ExtendedContext.copy_abs(Decimal('-100'))
04182         Decimal('100')
04183         >>> ExtendedContext.copy_abs(-1)
04184         Decimal('1')
04185         """
04186         a = _convert_other(a, raiseit=True)
04187         return a.copy_abs()

Here is the call graph for this function:

def decimal.Context.copy_decimal (   self,
  a 
)
Returns a copy of the decimal object.

>>> ExtendedContext.copy_decimal(Decimal('2.1'))
Decimal('2.1')
>>> ExtendedContext.copy_decimal(Decimal('-1.00'))
Decimal('-1.00')
>>> ExtendedContext.copy_decimal(1)
Decimal('1')

Definition at line 4188 of file decimal.py.

04188 
04189     def copy_decimal(self, a):
04190         """Returns a copy of the decimal object.
04191 
04192         >>> ExtendedContext.copy_decimal(Decimal('2.1'))
04193         Decimal('2.1')
04194         >>> ExtendedContext.copy_decimal(Decimal('-1.00'))
04195         Decimal('-1.00')
04196         >>> ExtendedContext.copy_decimal(1)
04197         Decimal('1')
04198         """
04199         a = _convert_other(a, raiseit=True)
04200         return Decimal(a)

Here is the call graph for this function:

def decimal.Context.copy_negate (   self,
  a 
)
Returns a copy of the operand with the sign inverted.

>>> ExtendedContext.copy_negate(Decimal('101.5'))
Decimal('-101.5')
>>> ExtendedContext.copy_negate(Decimal('-101.5'))
Decimal('101.5')
>>> ExtendedContext.copy_negate(1)
Decimal('-1')

Definition at line 4201 of file decimal.py.

04201 
04202     def copy_negate(self, a):
04203         """Returns a copy of the operand with the sign inverted.
04204 
04205         >>> ExtendedContext.copy_negate(Decimal('101.5'))
04206         Decimal('-101.5')
04207         >>> ExtendedContext.copy_negate(Decimal('-101.5'))
04208         Decimal('101.5')
04209         >>> ExtendedContext.copy_negate(1)
04210         Decimal('-1')
04211         """
04212         a = _convert_other(a, raiseit=True)
04213         return a.copy_negate()

Here is the call graph for this function:

def decimal.Context.copy_sign (   self,
  a,
  b 
)
Copies the second operand's sign to the first one.

In detail, it returns a copy of the first operand with the sign
equal to the sign of the second operand.

>>> ExtendedContext.copy_sign(Decimal( '1.50'), Decimal('7.33'))
Decimal('1.50')
>>> ExtendedContext.copy_sign(Decimal('-1.50'), Decimal('7.33'))
Decimal('1.50')
>>> ExtendedContext.copy_sign(Decimal( '1.50'), Decimal('-7.33'))
Decimal('-1.50')
>>> ExtendedContext.copy_sign(Decimal('-1.50'), Decimal('-7.33'))
Decimal('-1.50')
>>> ExtendedContext.copy_sign(1, -2)
Decimal('-1')
>>> ExtendedContext.copy_sign(Decimal(1), -2)
Decimal('-1')
>>> ExtendedContext.copy_sign(1, Decimal(-2))
Decimal('-1')

Definition at line 4214 of file decimal.py.

04214 
04215     def copy_sign(self, a, b):
04216         """Copies the second operand's sign to the first one.
04217 
04218         In detail, it returns a copy of the first operand with the sign
04219         equal to the sign of the second operand.
04220 
04221         >>> ExtendedContext.copy_sign(Decimal( '1.50'), Decimal('7.33'))
04222         Decimal('1.50')
04223         >>> ExtendedContext.copy_sign(Decimal('-1.50'), Decimal('7.33'))
04224         Decimal('1.50')
04225         >>> ExtendedContext.copy_sign(Decimal( '1.50'), Decimal('-7.33'))
04226         Decimal('-1.50')
04227         >>> ExtendedContext.copy_sign(Decimal('-1.50'), Decimal('-7.33'))
04228         Decimal('-1.50')
04229         >>> ExtendedContext.copy_sign(1, -2)
04230         Decimal('-1')
04231         >>> ExtendedContext.copy_sign(Decimal(1), -2)
04232         Decimal('-1')
04233         >>> ExtendedContext.copy_sign(1, Decimal(-2))
04234         Decimal('-1')
04235         """
04236         a = _convert_other(a, raiseit=True)
04237         return a.copy_sign(b)

Here is the call graph for this function:

def decimal.Context.create_decimal (   self,
  num = '0' 
)
Creates a new Decimal instance but using self as context.

This method implements the to-number operation of the
IBM Decimal specification.

Definition at line 3976 of file decimal.py.

03976 
03977     def create_decimal(self, num='0'):
03978         """Creates a new Decimal instance but using self as context.
03979 
03980         This method implements the to-number operation of the
03981         IBM Decimal specification."""
03982 
03983         if isinstance(num, str) and num != num.strip():
03984             return self._raise_error(ConversionSyntax,
03985                                      "no trailing or leading whitespace is "
03986                                      "permitted.")
03987 
03988         d = Decimal(num, context=self)
03989         if d._isnan() and len(d._int) > self.prec - self.clamp:
03990             return self._raise_error(ConversionSyntax,
03991                                      "diagnostic info too long in NaN")
03992         return d._fix(self)

Here is the call graph for this function:

Creates a new Decimal instance from a float but rounding using self
as the context.

>>> context = Context(prec=5, rounding=ROUND_DOWN)
>>> context.create_decimal_from_float(3.1415926535897932)
Decimal('3.1415')
>>> context = Context(prec=5, traps=[Inexact])
>>> context.create_decimal_from_float(3.1415926535897932)
Traceback (most recent call last):
    ...
decimal.Inexact: None

Definition at line 3993 of file decimal.py.

03993 
03994     def create_decimal_from_float(self, f):
03995         """Creates a new Decimal instance from a float but rounding using self
03996         as the context.
03997 
03998         >>> context = Context(prec=5, rounding=ROUND_DOWN)
03999         >>> context.create_decimal_from_float(3.1415926535897932)
04000         Decimal('3.1415')
04001         >>> context = Context(prec=5, traps=[Inexact])
04002         >>> context.create_decimal_from_float(3.1415926535897932)
04003         Traceback (most recent call last):
04004             ...
04005         decimal.Inexact: None
04006 
04007         """
04008         d = Decimal.from_float(f)       # An exact conversion
04009         return d._fix(self)             # Apply the context rounding

def decimal.Context.divide (   self,
  a,
  b 
)
Decimal division in a specified context.

>>> ExtendedContext.divide(Decimal('1'), Decimal('3'))
Decimal('0.333333333')
>>> ExtendedContext.divide(Decimal('2'), Decimal('3'))
Decimal('0.666666667')
>>> ExtendedContext.divide(Decimal('5'), Decimal('2'))
Decimal('2.5')
>>> ExtendedContext.divide(Decimal('1'), Decimal('10'))
Decimal('0.1')
>>> ExtendedContext.divide(Decimal('12'), Decimal('12'))
Decimal('1')
>>> ExtendedContext.divide(Decimal('8.00'), Decimal('2'))
Decimal('4.00')
>>> ExtendedContext.divide(Decimal('2.400'), Decimal('2.0'))
Decimal('1.20')
>>> ExtendedContext.divide(Decimal('1000'), Decimal('100'))
Decimal('10')
>>> ExtendedContext.divide(Decimal('1000'), Decimal('1'))
Decimal('1000')
>>> ExtendedContext.divide(Decimal('2.40E+6'), Decimal('2'))
Decimal('1.20E+6')
>>> ExtendedContext.divide(5, 5)
Decimal('1')
>>> ExtendedContext.divide(Decimal(5), 5)
Decimal('1')
>>> ExtendedContext.divide(5, Decimal(5))
Decimal('1')

Definition at line 4238 of file decimal.py.

04238 
04239     def divide(self, a, b):
04240         """Decimal division in a specified context.
04241 
04242         >>> ExtendedContext.divide(Decimal('1'), Decimal('3'))
04243         Decimal('0.333333333')
04244         >>> ExtendedContext.divide(Decimal('2'), Decimal('3'))
04245         Decimal('0.666666667')
04246         >>> ExtendedContext.divide(Decimal('5'), Decimal('2'))
04247         Decimal('2.5')
04248         >>> ExtendedContext.divide(Decimal('1'), Decimal('10'))
04249         Decimal('0.1')
04250         >>> ExtendedContext.divide(Decimal('12'), Decimal('12'))
04251         Decimal('1')
04252         >>> ExtendedContext.divide(Decimal('8.00'), Decimal('2'))
04253         Decimal('4.00')
04254         >>> ExtendedContext.divide(Decimal('2.400'), Decimal('2.0'))
04255         Decimal('1.20')
04256         >>> ExtendedContext.divide(Decimal('1000'), Decimal('100'))
04257         Decimal('10')
04258         >>> ExtendedContext.divide(Decimal('1000'), Decimal('1'))
04259         Decimal('1000')
04260         >>> ExtendedContext.divide(Decimal('2.40E+6'), Decimal('2'))
04261         Decimal('1.20E+6')
04262         >>> ExtendedContext.divide(5, 5)
04263         Decimal('1')
04264         >>> ExtendedContext.divide(Decimal(5), 5)
04265         Decimal('1')
04266         >>> ExtendedContext.divide(5, Decimal(5))
04267         Decimal('1')
04268         """
04269         a = _convert_other(a, raiseit=True)
04270         r = a.__truediv__(b, context=self)
04271         if r is NotImplemented:
04272             raise TypeError("Unable to convert %s to Decimal" % b)
04273         else:
04274             return r

Here is the call graph for this function:

def decimal.Context.divide_int (   self,
  a,
  b 
)
Divides two numbers and returns the integer part of the result.

>>> ExtendedContext.divide_int(Decimal('2'), Decimal('3'))
Decimal('0')
>>> ExtendedContext.divide_int(Decimal('10'), Decimal('3'))
Decimal('3')
>>> ExtendedContext.divide_int(Decimal('1'), Decimal('0.3'))
Decimal('3')
>>> ExtendedContext.divide_int(10, 3)
Decimal('3')
>>> ExtendedContext.divide_int(Decimal(10), 3)
Decimal('3')
>>> ExtendedContext.divide_int(10, Decimal(3))
Decimal('3')

Definition at line 4275 of file decimal.py.

04275 
04276     def divide_int(self, a, b):
04277         """Divides two numbers and returns the integer part of the result.
04278 
04279         >>> ExtendedContext.divide_int(Decimal('2'), Decimal('3'))
04280         Decimal('0')
04281         >>> ExtendedContext.divide_int(Decimal('10'), Decimal('3'))
04282         Decimal('3')
04283         >>> ExtendedContext.divide_int(Decimal('1'), Decimal('0.3'))
04284         Decimal('3')
04285         >>> ExtendedContext.divide_int(10, 3)
04286         Decimal('3')
04287         >>> ExtendedContext.divide_int(Decimal(10), 3)
04288         Decimal('3')
04289         >>> ExtendedContext.divide_int(10, Decimal(3))
04290         Decimal('3')
04291         """
04292         a = _convert_other(a, raiseit=True)
04293         r = a.__floordiv__(b, context=self)
04294         if r is NotImplemented:
04295             raise TypeError("Unable to convert %s to Decimal" % b)
04296         else:
04297             return r

Here is the call graph for this function:

def decimal.Context.divmod (   self,
  a,
  b 
)
Return (a // b, a % b).

>>> ExtendedContext.divmod(Decimal(8), Decimal(3))
(Decimal('2'), Decimal('2'))
>>> ExtendedContext.divmod(Decimal(8), Decimal(4))
(Decimal('2'), Decimal('0'))
>>> ExtendedContext.divmod(8, 4)
(Decimal('2'), Decimal('0'))
>>> ExtendedContext.divmod(Decimal(8), 4)
(Decimal('2'), Decimal('0'))
>>> ExtendedContext.divmod(8, Decimal(4))
(Decimal('2'), Decimal('0'))

Definition at line 4298 of file decimal.py.

04298 
04299     def divmod(self, a, b):
04300         """Return (a // b, a % b).
04301 
04302         >>> ExtendedContext.divmod(Decimal(8), Decimal(3))
04303         (Decimal('2'), Decimal('2'))
04304         >>> ExtendedContext.divmod(Decimal(8), Decimal(4))
04305         (Decimal('2'), Decimal('0'))
04306         >>> ExtendedContext.divmod(8, 4)
04307         (Decimal('2'), Decimal('0'))
04308         >>> ExtendedContext.divmod(Decimal(8), 4)
04309         (Decimal('2'), Decimal('0'))
04310         >>> ExtendedContext.divmod(8, Decimal(4))
04311         (Decimal('2'), Decimal('0'))
04312         """
04313         a = _convert_other(a, raiseit=True)
04314         r = a.__divmod__(b, context=self)
04315         if r is NotImplemented:
04316             raise TypeError("Unable to convert %s to Decimal" % b)
04317         else:
04318             return r

Here is the call graph for this function:

def decimal.Context.Etiny (   self)
Returns Etiny (= Emin - prec + 1)

Definition at line 3949 of file decimal.py.

03949 
03950     def Etiny(self):
03951         """Returns Etiny (= Emin - prec + 1)"""
03952         return int(self.Emin - self.prec + 1)

def decimal.Context.Etop (   self)
Returns maximum exponent (= Emax - prec + 1)

Definition at line 3953 of file decimal.py.

03953 
03954     def Etop(self):
03955         """Returns maximum exponent (= Emax - prec + 1)"""
03956         return int(self.Emax - self.prec + 1)

def decimal.Context.exp (   self,
  a 
)
Returns e ** a.

>>> c = ExtendedContext.copy()
>>> c.Emin = -999
>>> c.Emax = 999
>>> c.exp(Decimal('-Infinity'))
Decimal('0')
>>> c.exp(Decimal('-1'))
Decimal('0.367879441')
>>> c.exp(Decimal('0'))
Decimal('1')
>>> c.exp(Decimal('1'))
Decimal('2.71828183')
>>> c.exp(Decimal('0.693147181'))
Decimal('2.00000000')
>>> c.exp(Decimal('+Infinity'))
Decimal('Infinity')
>>> c.exp(10)
Decimal('22026.4658')

Definition at line 4319 of file decimal.py.

04319 
04320     def exp(self, a):
04321         """Returns e ** a.
04322 
04323         >>> c = ExtendedContext.copy()
04324         >>> c.Emin = -999
04325         >>> c.Emax = 999
04326         >>> c.exp(Decimal('-Infinity'))
04327         Decimal('0')
04328         >>> c.exp(Decimal('-1'))
04329         Decimal('0.367879441')
04330         >>> c.exp(Decimal('0'))
04331         Decimal('1')
04332         >>> c.exp(Decimal('1'))
04333         Decimal('2.71828183')
04334         >>> c.exp(Decimal('0.693147181'))
04335         Decimal('2.00000000')
04336         >>> c.exp(Decimal('+Infinity'))
04337         Decimal('Infinity')
04338         >>> c.exp(10)
04339         Decimal('22026.4658')
04340         """
04341         a =_convert_other(a, raiseit=True)
04342         return a.exp(context=self)

Here is the call graph for this function:

def decimal.Context.fma (   self,
  a,
  b,
  c 
)
Returns a multiplied by b, plus c.

The first two operands are multiplied together, using multiply,
the third operand is then added to the result of that
multiplication, using add, all with only one final rounding.

>>> ExtendedContext.fma(Decimal('3'), Decimal('5'), Decimal('7'))
Decimal('22')
>>> ExtendedContext.fma(Decimal('3'), Decimal('-5'), Decimal('7'))
Decimal('-8')
>>> ExtendedContext.fma(Decimal('888565290'), Decimal('1557.96930'), Decimal('-86087.7578'))
Decimal('1.38435736E+12')
>>> ExtendedContext.fma(1, 3, 4)
Decimal('7')
>>> ExtendedContext.fma(1, Decimal(3), 4)
Decimal('7')
>>> ExtendedContext.fma(1, 3, Decimal(4))
Decimal('7')

Definition at line 4343 of file decimal.py.

04343 
04344     def fma(self, a, b, c):
04345         """Returns a multiplied by b, plus c.
04346 
04347         The first two operands are multiplied together, using multiply,
04348         the third operand is then added to the result of that
04349         multiplication, using add, all with only one final rounding.
04350 
04351         >>> ExtendedContext.fma(Decimal('3'), Decimal('5'), Decimal('7'))
04352         Decimal('22')
04353         >>> ExtendedContext.fma(Decimal('3'), Decimal('-5'), Decimal('7'))
04354         Decimal('-8')
04355         >>> ExtendedContext.fma(Decimal('888565290'), Decimal('1557.96930'), Decimal('-86087.7578'))
04356         Decimal('1.38435736E+12')
04357         >>> ExtendedContext.fma(1, 3, 4)
04358         Decimal('7')
04359         >>> ExtendedContext.fma(1, Decimal(3), 4)
04360         Decimal('7')
04361         >>> ExtendedContext.fma(1, 3, Decimal(4))
04362         Decimal('7')
04363         """
04364         a = _convert_other(a, raiseit=True)
04365         return a.fma(b, c, context=self)

Here is the call graph for this function:

def decimal.Context.is_canonical (   self,
  a 
)
Return True if the operand is canonical; otherwise return False.

Currently, the encoding of a Decimal instance is always
canonical, so this method returns True for any Decimal.

>>> ExtendedContext.is_canonical(Decimal('2.50'))
True

Definition at line 4366 of file decimal.py.

04366 
04367     def is_canonical(self, a):
04368         """Return True if the operand is canonical; otherwise return False.
04369 
04370         Currently, the encoding of a Decimal instance is always
04371         canonical, so this method returns True for any Decimal.
04372 
04373         >>> ExtendedContext.is_canonical(Decimal('2.50'))
04374         True
04375         """
04376         return a.is_canonical()

def decimal.Context.is_finite (   self,
  a 
)
Return True if the operand is finite; otherwise return False.

A Decimal instance is considered finite if it is neither
infinite nor a NaN.

>>> ExtendedContext.is_finite(Decimal('2.50'))
True
>>> ExtendedContext.is_finite(Decimal('-0.3'))
True
>>> ExtendedContext.is_finite(Decimal('0'))
True
>>> ExtendedContext.is_finite(Decimal('Inf'))
False
>>> ExtendedContext.is_finite(Decimal('NaN'))
False
>>> ExtendedContext.is_finite(1)
True

Definition at line 4377 of file decimal.py.

04377 
04378     def is_finite(self, a):
04379         """Return True if the operand is finite; otherwise return False.
04380 
04381         A Decimal instance is considered finite if it is neither
04382         infinite nor a NaN.
04383 
04384         >>> ExtendedContext.is_finite(Decimal('2.50'))
04385         True
04386         >>> ExtendedContext.is_finite(Decimal('-0.3'))
04387         True
04388         >>> ExtendedContext.is_finite(Decimal('0'))
04389         True
04390         >>> ExtendedContext.is_finite(Decimal('Inf'))
04391         False
04392         >>> ExtendedContext.is_finite(Decimal('NaN'))
04393         False
04394         >>> ExtendedContext.is_finite(1)
04395         True
04396         """
04397         a = _convert_other(a, raiseit=True)
04398         return a.is_finite()

Here is the call graph for this function:

def decimal.Context.is_infinite (   self,
  a 
)
Return True if the operand is infinite; otherwise return False.

>>> ExtendedContext.is_infinite(Decimal('2.50'))
False
>>> ExtendedContext.is_infinite(Decimal('-Inf'))
True
>>> ExtendedContext.is_infinite(Decimal('NaN'))
False
>>> ExtendedContext.is_infinite(1)
False

Definition at line 4399 of file decimal.py.

04399 
04400     def is_infinite(self, a):
04401         """Return True if the operand is infinite; otherwise return False.
04402 
04403         >>> ExtendedContext.is_infinite(Decimal('2.50'))
04404         False
04405         >>> ExtendedContext.is_infinite(Decimal('-Inf'))
04406         True
04407         >>> ExtendedContext.is_infinite(Decimal('NaN'))
04408         False
04409         >>> ExtendedContext.is_infinite(1)
04410         False
04411         """
04412         a = _convert_other(a, raiseit=True)
04413         return a.is_infinite()

Here is the call graph for this function:

def decimal.Context.is_nan (   self,
  a 
)
Return True if the operand is a qNaN or sNaN;
otherwise return False.

>>> ExtendedContext.is_nan(Decimal('2.50'))
False
>>> ExtendedContext.is_nan(Decimal('NaN'))
True
>>> ExtendedContext.is_nan(Decimal('-sNaN'))
True
>>> ExtendedContext.is_nan(1)
False

Definition at line 4414 of file decimal.py.

04414 
04415     def is_nan(self, a):
04416         """Return True if the operand is a qNaN or sNaN;
04417         otherwise return False.
04418 
04419         >>> ExtendedContext.is_nan(Decimal('2.50'))
04420         False
04421         >>> ExtendedContext.is_nan(Decimal('NaN'))
04422         True
04423         >>> ExtendedContext.is_nan(Decimal('-sNaN'))
04424         True
04425         >>> ExtendedContext.is_nan(1)
04426         False
04427         """
04428         a = _convert_other(a, raiseit=True)
04429         return a.is_nan()

Here is the call graph for this function:

def decimal.Context.is_normal (   self,
  a 
)
Return True if the operand is a normal number;
otherwise return False.

>>> c = ExtendedContext.copy()
>>> c.Emin = -999
>>> c.Emax = 999
>>> c.is_normal(Decimal('2.50'))
True
>>> c.is_normal(Decimal('0.1E-999'))
False
>>> c.is_normal(Decimal('0.00'))
False
>>> c.is_normal(Decimal('-Inf'))
False
>>> c.is_normal(Decimal('NaN'))
False
>>> c.is_normal(1)
True

Definition at line 4430 of file decimal.py.

04430 
04431     def is_normal(self, a):
04432         """Return True if the operand is a normal number;
04433         otherwise return False.
04434 
04435         >>> c = ExtendedContext.copy()
04436         >>> c.Emin = -999
04437         >>> c.Emax = 999
04438         >>> c.is_normal(Decimal('2.50'))
04439         True
04440         >>> c.is_normal(Decimal('0.1E-999'))
04441         False
04442         >>> c.is_normal(Decimal('0.00'))
04443         False
04444         >>> c.is_normal(Decimal('-Inf'))
04445         False
04446         >>> c.is_normal(Decimal('NaN'))
04447         False
04448         >>> c.is_normal(1)
04449         True
04450         """
04451         a = _convert_other(a, raiseit=True)
04452         return a.is_normal(context=self)

Here is the call graph for this function:

def decimal.Context.is_qnan (   self,
  a 
)
Return True if the operand is a quiet NaN; otherwise return False.

>>> ExtendedContext.is_qnan(Decimal('2.50'))
False
>>> ExtendedContext.is_qnan(Decimal('NaN'))
True
>>> ExtendedContext.is_qnan(Decimal('sNaN'))
False
>>> ExtendedContext.is_qnan(1)
False

Definition at line 4453 of file decimal.py.

04453 
04454     def is_qnan(self, a):
04455         """Return True if the operand is a quiet NaN; otherwise return False.
04456 
04457         >>> ExtendedContext.is_qnan(Decimal('2.50'))
04458         False
04459         >>> ExtendedContext.is_qnan(Decimal('NaN'))
04460         True
04461         >>> ExtendedContext.is_qnan(Decimal('sNaN'))
04462         False
04463         >>> ExtendedContext.is_qnan(1)
04464         False
04465         """
04466         a = _convert_other(a, raiseit=True)
04467         return a.is_qnan()

Here is the call graph for this function:

def decimal.Context.is_signed (   self,
  a 
)
Return True if the operand is negative; otherwise return False.

>>> ExtendedContext.is_signed(Decimal('2.50'))
False
>>> ExtendedContext.is_signed(Decimal('-12'))
True
>>> ExtendedContext.is_signed(Decimal('-0'))
True
>>> ExtendedContext.is_signed(8)
False
>>> ExtendedContext.is_signed(-8)
True

Definition at line 4468 of file decimal.py.

04468 
04469     def is_signed(self, a):
04470         """Return True if the operand is negative; otherwise return False.
04471 
04472         >>> ExtendedContext.is_signed(Decimal('2.50'))
04473         False
04474         >>> ExtendedContext.is_signed(Decimal('-12'))
04475         True
04476         >>> ExtendedContext.is_signed(Decimal('-0'))
04477         True
04478         >>> ExtendedContext.is_signed(8)
04479         False
04480         >>> ExtendedContext.is_signed(-8)
04481         True
04482         """
04483         a = _convert_other(a, raiseit=True)
04484         return a.is_signed()

Here is the call graph for this function:

def decimal.Context.is_snan (   self,
  a 
)
Return True if the operand is a signaling NaN;
otherwise return False.

>>> ExtendedContext.is_snan(Decimal('2.50'))
False
>>> ExtendedContext.is_snan(Decimal('NaN'))
False
>>> ExtendedContext.is_snan(Decimal('sNaN'))
True
>>> ExtendedContext.is_snan(1)
False

Definition at line 4485 of file decimal.py.

04485 
04486     def is_snan(self, a):
04487         """Return True if the operand is a signaling NaN;
04488         otherwise return False.
04489 
04490         >>> ExtendedContext.is_snan(Decimal('2.50'))
04491         False
04492         >>> ExtendedContext.is_snan(Decimal('NaN'))
04493         False
04494         >>> ExtendedContext.is_snan(Decimal('sNaN'))
04495         True
04496         >>> ExtendedContext.is_snan(1)
04497         False
04498         """
04499         a = _convert_other(a, raiseit=True)
04500         return a.is_snan()

Here is the call graph for this function:

def decimal.Context.is_subnormal (   self,
  a 
)
Return True if the operand is subnormal; otherwise return False.

>>> c = ExtendedContext.copy()
>>> c.Emin = -999
>>> c.Emax = 999
>>> c.is_subnormal(Decimal('2.50'))
False
>>> c.is_subnormal(Decimal('0.1E-999'))
True
>>> c.is_subnormal(Decimal('0.00'))
False
>>> c.is_subnormal(Decimal('-Inf'))
False
>>> c.is_subnormal(Decimal('NaN'))
False
>>> c.is_subnormal(1)
False

Definition at line 4501 of file decimal.py.

04501 
04502     def is_subnormal(self, a):
04503         """Return True if the operand is subnormal; otherwise return False.
04504 
04505         >>> c = ExtendedContext.copy()
04506         >>> c.Emin = -999
04507         >>> c.Emax = 999
04508         >>> c.is_subnormal(Decimal('2.50'))
04509         False
04510         >>> c.is_subnormal(Decimal('0.1E-999'))
04511         True
04512         >>> c.is_subnormal(Decimal('0.00'))
04513         False
04514         >>> c.is_subnormal(Decimal('-Inf'))
04515         False
04516         >>> c.is_subnormal(Decimal('NaN'))
04517         False
04518         >>> c.is_subnormal(1)
04519         False
04520         """
04521         a = _convert_other(a, raiseit=True)
04522         return a.is_subnormal(context=self)

Here is the call graph for this function:

def decimal.Context.is_zero (   self,
  a 
)
Return True if the operand is a zero; otherwise return False.

>>> ExtendedContext.is_zero(Decimal('0'))
True
>>> ExtendedContext.is_zero(Decimal('2.50'))
False
>>> ExtendedContext.is_zero(Decimal('-0E+2'))
True
>>> ExtendedContext.is_zero(1)
False
>>> ExtendedContext.is_zero(0)
True

Definition at line 4523 of file decimal.py.

04523 
04524     def is_zero(self, a):
04525         """Return True if the operand is a zero; otherwise return False.
04526 
04527         >>> ExtendedContext.is_zero(Decimal('0'))
04528         True
04529         >>> ExtendedContext.is_zero(Decimal('2.50'))
04530         False
04531         >>> ExtendedContext.is_zero(Decimal('-0E+2'))
04532         True
04533         >>> ExtendedContext.is_zero(1)
04534         False
04535         >>> ExtendedContext.is_zero(0)
04536         True
04537         """
04538         a = _convert_other(a, raiseit=True)
04539         return a.is_zero()

Here is the call graph for this function:

def decimal.Context.ln (   self,
  a 
)
Returns the natural (base e) logarithm of the operand.

>>> c = ExtendedContext.copy()
>>> c.Emin = -999
>>> c.Emax = 999
>>> c.ln(Decimal('0'))
Decimal('-Infinity')
>>> c.ln(Decimal('1.000'))
Decimal('0')
>>> c.ln(Decimal('2.71828183'))
Decimal('1.00000000')
>>> c.ln(Decimal('10'))
Decimal('2.30258509')
>>> c.ln(Decimal('+Infinity'))
Decimal('Infinity')
>>> c.ln(1)
Decimal('0')

Definition at line 4540 of file decimal.py.

04540 
04541     def ln(self, a):
04542         """Returns the natural (base e) logarithm of the operand.
04543 
04544         >>> c = ExtendedContext.copy()
04545         >>> c.Emin = -999
04546         >>> c.Emax = 999
04547         >>> c.ln(Decimal('0'))
04548         Decimal('-Infinity')
04549         >>> c.ln(Decimal('1.000'))
04550         Decimal('0')
04551         >>> c.ln(Decimal('2.71828183'))
04552         Decimal('1.00000000')
04553         >>> c.ln(Decimal('10'))
04554         Decimal('2.30258509')
04555         >>> c.ln(Decimal('+Infinity'))
04556         Decimal('Infinity')
04557         >>> c.ln(1)
04558         Decimal('0')
04559         """
04560         a = _convert_other(a, raiseit=True)
04561         return a.ln(context=self)

Here is the call graph for this function:

def decimal.Context.log10 (   self,
  a 
)
Returns the base 10 logarithm of the operand.

>>> c = ExtendedContext.copy()
>>> c.Emin = -999
>>> c.Emax = 999
>>> c.log10(Decimal('0'))
Decimal('-Infinity')
>>> c.log10(Decimal('0.001'))
Decimal('-3')
>>> c.log10(Decimal('1.000'))
Decimal('0')
>>> c.log10(Decimal('2'))
Decimal('0.301029996')
>>> c.log10(Decimal('10'))
Decimal('1')
>>> c.log10(Decimal('70'))
Decimal('1.84509804')
>>> c.log10(Decimal('+Infinity'))
Decimal('Infinity')
>>> c.log10(0)
Decimal('-Infinity')
>>> c.log10(1)
Decimal('0')

Definition at line 4562 of file decimal.py.

04562 
04563     def log10(self, a):
04564         """Returns the base 10 logarithm of the operand.
04565 
04566         >>> c = ExtendedContext.copy()
04567         >>> c.Emin = -999
04568         >>> c.Emax = 999
04569         >>> c.log10(Decimal('0'))
04570         Decimal('-Infinity')
04571         >>> c.log10(Decimal('0.001'))
04572         Decimal('-3')
04573         >>> c.log10(Decimal('1.000'))
04574         Decimal('0')
04575         >>> c.log10(Decimal('2'))
04576         Decimal('0.301029996')
04577         >>> c.log10(Decimal('10'))
04578         Decimal('1')
04579         >>> c.log10(Decimal('70'))
04580         Decimal('1.84509804')
04581         >>> c.log10(Decimal('+Infinity'))
04582         Decimal('Infinity')
04583         >>> c.log10(0)
04584         Decimal('-Infinity')
04585         >>> c.log10(1)
04586         Decimal('0')
04587         """
04588         a = _convert_other(a, raiseit=True)
04589         return a.log10(context=self)

Here is the call graph for this function:

def decimal.Context.logb (   self,
  a 
)
Returns the exponent of the magnitude of the operand's MSD.

The result is the integer which is the exponent of the magnitude
of the most significant digit of the operand (as though the
operand were truncated to a single digit while maintaining the
value of that digit and without limiting the resulting exponent).

>>> ExtendedContext.logb(Decimal('250'))
Decimal('2')
>>> ExtendedContext.logb(Decimal('2.50'))
Decimal('0')
>>> ExtendedContext.logb(Decimal('0.03'))
Decimal('-2')
>>> ExtendedContext.logb(Decimal('0'))
Decimal('-Infinity')
>>> ExtendedContext.logb(1)
Decimal('0')
>>> ExtendedContext.logb(10)
Decimal('1')
>>> ExtendedContext.logb(100)
Decimal('2')

Definition at line 4590 of file decimal.py.

04590 
04591     def logb(self, a):
04592         """ Returns the exponent of the magnitude of the operand's MSD.
04593 
04594         The result is the integer which is the exponent of the magnitude
04595         of the most significant digit of the operand (as though the
04596         operand were truncated to a single digit while maintaining the
04597         value of that digit and without limiting the resulting exponent).
04598 
04599         >>> ExtendedContext.logb(Decimal('250'))
04600         Decimal('2')
04601         >>> ExtendedContext.logb(Decimal('2.50'))
04602         Decimal('0')
04603         >>> ExtendedContext.logb(Decimal('0.03'))
04604         Decimal('-2')
04605         >>> ExtendedContext.logb(Decimal('0'))
04606         Decimal('-Infinity')
04607         >>> ExtendedContext.logb(1)
04608         Decimal('0')
04609         >>> ExtendedContext.logb(10)
04610         Decimal('1')
04611         >>> ExtendedContext.logb(100)
04612         Decimal('2')
04613         """
04614         a = _convert_other(a, raiseit=True)
04615         return a.logb(context=self)

Here is the call graph for this function:

def decimal.Context.logical_and (   self,
  a,
  b 
)
Applies the logical operation 'and' between each operand's digits.

The operands must be both logical numbers.

>>> ExtendedContext.logical_and(Decimal('0'), Decimal('0'))
Decimal('0')
>>> ExtendedContext.logical_and(Decimal('0'), Decimal('1'))
Decimal('0')
>>> ExtendedContext.logical_and(Decimal('1'), Decimal('0'))
Decimal('0')
>>> ExtendedContext.logical_and(Decimal('1'), Decimal('1'))
Decimal('1')
>>> ExtendedContext.logical_and(Decimal('1100'), Decimal('1010'))
Decimal('1000')
>>> ExtendedContext.logical_and(Decimal('1111'), Decimal('10'))
Decimal('10')
>>> ExtendedContext.logical_and(110, 1101)
Decimal('100')
>>> ExtendedContext.logical_and(Decimal(110), 1101)
Decimal('100')
>>> ExtendedContext.logical_and(110, Decimal(1101))
Decimal('100')

Definition at line 4616 of file decimal.py.

04616 
04617     def logical_and(self, a, b):
04618         """Applies the logical operation 'and' between each operand's digits.
04619 
04620         The operands must be both logical numbers.
04621 
04622         >>> ExtendedContext.logical_and(Decimal('0'), Decimal('0'))
04623         Decimal('0')
04624         >>> ExtendedContext.logical_and(Decimal('0'), Decimal('1'))
04625         Decimal('0')
04626         >>> ExtendedContext.logical_and(Decimal('1'), Decimal('0'))
04627         Decimal('0')
04628         >>> ExtendedContext.logical_and(Decimal('1'), Decimal('1'))
04629         Decimal('1')
04630         >>> ExtendedContext.logical_and(Decimal('1100'), Decimal('1010'))
04631         Decimal('1000')
04632         >>> ExtendedContext.logical_and(Decimal('1111'), Decimal('10'))
04633         Decimal('10')
04634         >>> ExtendedContext.logical_and(110, 1101)
04635         Decimal('100')
04636         >>> ExtendedContext.logical_and(Decimal(110), 1101)
04637         Decimal('100')
04638         >>> ExtendedContext.logical_and(110, Decimal(1101))
04639         Decimal('100')
04640         """
04641         a = _convert_other(a, raiseit=True)
04642         return a.logical_and(b, context=self)

Here is the call graph for this function:

def decimal.Context.logical_invert (   self,
  a 
)
Invert all the digits in the operand.

The operand must be a logical number.

>>> ExtendedContext.logical_invert(Decimal('0'))
Decimal('111111111')
>>> ExtendedContext.logical_invert(Decimal('1'))
Decimal('111111110')
>>> ExtendedContext.logical_invert(Decimal('111111111'))
Decimal('0')
>>> ExtendedContext.logical_invert(Decimal('101010101'))
Decimal('10101010')
>>> ExtendedContext.logical_invert(1101)
Decimal('111110010')

Definition at line 4643 of file decimal.py.

04643 
04644     def logical_invert(self, a):
04645         """Invert all the digits in the operand.
04646 
04647         The operand must be a logical number.
04648 
04649         >>> ExtendedContext.logical_invert(Decimal('0'))
04650         Decimal('111111111')
04651         >>> ExtendedContext.logical_invert(Decimal('1'))
04652         Decimal('111111110')
04653         >>> ExtendedContext.logical_invert(Decimal('111111111'))
04654         Decimal('0')
04655         >>> ExtendedContext.logical_invert(Decimal('101010101'))
04656         Decimal('10101010')
04657         >>> ExtendedContext.logical_invert(1101)
04658         Decimal('111110010')
04659         """
04660         a = _convert_other(a, raiseit=True)
04661         return a.logical_invert(context=self)

Here is the call graph for this function:

def decimal.Context.logical_or (   self,
  a,
  b 
)
Applies the logical operation 'or' between each operand's digits.

The operands must be both logical numbers.

>>> ExtendedContext.logical_or(Decimal('0'), Decimal('0'))
Decimal('0')
>>> ExtendedContext.logical_or(Decimal('0'), Decimal('1'))
Decimal('1')
>>> ExtendedContext.logical_or(Decimal('1'), Decimal('0'))
Decimal('1')
>>> ExtendedContext.logical_or(Decimal('1'), Decimal('1'))
Decimal('1')
>>> ExtendedContext.logical_or(Decimal('1100'), Decimal('1010'))
Decimal('1110')
>>> ExtendedContext.logical_or(Decimal('1110'), Decimal('10'))
Decimal('1110')
>>> ExtendedContext.logical_or(110, 1101)
Decimal('1111')
>>> ExtendedContext.logical_or(Decimal(110), 1101)
Decimal('1111')
>>> ExtendedContext.logical_or(110, Decimal(1101))
Decimal('1111')

Definition at line 4662 of file decimal.py.

04662 
04663     def logical_or(self, a, b):
04664         """Applies the logical operation 'or' between each operand's digits.
04665 
04666         The operands must be both logical numbers.
04667 
04668         >>> ExtendedContext.logical_or(Decimal('0'), Decimal('0'))
04669         Decimal('0')
04670         >>> ExtendedContext.logical_or(Decimal('0'), Decimal('1'))
04671         Decimal('1')
04672         >>> ExtendedContext.logical_or(Decimal('1'), Decimal('0'))
04673         Decimal('1')
04674         >>> ExtendedContext.logical_or(Decimal('1'), Decimal('1'))
04675         Decimal('1')
04676         >>> ExtendedContext.logical_or(Decimal('1100'), Decimal('1010'))
04677         Decimal('1110')
04678         >>> ExtendedContext.logical_or(Decimal('1110'), Decimal('10'))
04679         Decimal('1110')
04680         >>> ExtendedContext.logical_or(110, 1101)
04681         Decimal('1111')
04682         >>> ExtendedContext.logical_or(Decimal(110), 1101)
04683         Decimal('1111')
04684         >>> ExtendedContext.logical_or(110, Decimal(1101))
04685         Decimal('1111')
04686         """
04687         a = _convert_other(a, raiseit=True)
04688         return a.logical_or(b, context=self)

Here is the call graph for this function:

def decimal.Context.logical_xor (   self,
  a,
  b 
)
Applies the logical operation 'xor' between each operand's digits.

The operands must be both logical numbers.

>>> ExtendedContext.logical_xor(Decimal('0'), Decimal('0'))
Decimal('0')
>>> ExtendedContext.logical_xor(Decimal('0'), Decimal('1'))
Decimal('1')
>>> ExtendedContext.logical_xor(Decimal('1'), Decimal('0'))
Decimal('1')
>>> ExtendedContext.logical_xor(Decimal('1'), Decimal('1'))
Decimal('0')
>>> ExtendedContext.logical_xor(Decimal('1100'), Decimal('1010'))
Decimal('110')
>>> ExtendedContext.logical_xor(Decimal('1111'), Decimal('10'))
Decimal('1101')
>>> ExtendedContext.logical_xor(110, 1101)
Decimal('1011')
>>> ExtendedContext.logical_xor(Decimal(110), 1101)
Decimal('1011')
>>> ExtendedContext.logical_xor(110, Decimal(1101))
Decimal('1011')

Definition at line 4689 of file decimal.py.

04689 
04690     def logical_xor(self, a, b):
04691         """Applies the logical operation 'xor' between each operand's digits.
04692 
04693         The operands must be both logical numbers.
04694 
04695         >>> ExtendedContext.logical_xor(Decimal('0'), Decimal('0'))
04696         Decimal('0')
04697         >>> ExtendedContext.logical_xor(Decimal('0'), Decimal('1'))
04698         Decimal('1')
04699         >>> ExtendedContext.logical_xor(Decimal('1'), Decimal('0'))
04700         Decimal('1')
04701         >>> ExtendedContext.logical_xor(Decimal('1'), Decimal('1'))
04702         Decimal('0')
04703         >>> ExtendedContext.logical_xor(Decimal('1100'), Decimal('1010'))
04704         Decimal('110')
04705         >>> ExtendedContext.logical_xor(Decimal('1111'), Decimal('10'))
04706         Decimal('1101')
04707         >>> ExtendedContext.logical_xor(110, 1101)
04708         Decimal('1011')
04709         >>> ExtendedContext.logical_xor(Decimal(110), 1101)
04710         Decimal('1011')
04711         >>> ExtendedContext.logical_xor(110, Decimal(1101))
04712         Decimal('1011')
04713         """
04714         a = _convert_other(a, raiseit=True)
04715         return a.logical_xor(b, context=self)

Here is the call graph for this function:

def decimal.Context.max (   self,
  a,
  b 
)
max compares two values numerically and returns the maximum.

If either operand is a NaN then the general rules apply.
Otherwise, the operands are compared as though by the compare
operation.  If they are numerically equal then the left-hand operand
is chosen as the result.  Otherwise the maximum (closer to positive
infinity) of the two operands is chosen as the result.

>>> ExtendedContext.max(Decimal('3'), Decimal('2'))
Decimal('3')
>>> ExtendedContext.max(Decimal('-10'), Decimal('3'))
Decimal('3')
>>> ExtendedContext.max(Decimal('1.0'), Decimal('1'))
Decimal('1')
>>> ExtendedContext.max(Decimal('7'), Decimal('NaN'))
Decimal('7')
>>> ExtendedContext.max(1, 2)
Decimal('2')
>>> ExtendedContext.max(Decimal(1), 2)
Decimal('2')
>>> ExtendedContext.max(1, Decimal(2))
Decimal('2')

Definition at line 4716 of file decimal.py.

04716 
04717     def max(self, a, b):
04718         """max compares two values numerically and returns the maximum.
04719 
04720         If either operand is a NaN then the general rules apply.
04721         Otherwise, the operands are compared as though by the compare
04722         operation.  If they are numerically equal then the left-hand operand
04723         is chosen as the result.  Otherwise the maximum (closer to positive
04724         infinity) of the two operands is chosen as the result.
04725 
04726         >>> ExtendedContext.max(Decimal('3'), Decimal('2'))
04727         Decimal('3')
04728         >>> ExtendedContext.max(Decimal('-10'), Decimal('3'))
04729         Decimal('3')
04730         >>> ExtendedContext.max(Decimal('1.0'), Decimal('1'))
04731         Decimal('1')
04732         >>> ExtendedContext.max(Decimal('7'), Decimal('NaN'))
04733         Decimal('7')
04734         >>> ExtendedContext.max(1, 2)
04735         Decimal('2')
04736         >>> ExtendedContext.max(Decimal(1), 2)
04737         Decimal('2')
04738         >>> ExtendedContext.max(1, Decimal(2))
04739         Decimal('2')
04740         """
04741         a = _convert_other(a, raiseit=True)
04742         return a.max(b, context=self)

Here is the call graph for this function:

def decimal.Context.max_mag (   self,
  a,
  b 
)
Compares the values numerically with their sign ignored.

>>> ExtendedContext.max_mag(Decimal('7'), Decimal('NaN'))
Decimal('7')
>>> ExtendedContext.max_mag(Decimal('7'), Decimal('-10'))
Decimal('-10')
>>> ExtendedContext.max_mag(1, -2)
Decimal('-2')
>>> ExtendedContext.max_mag(Decimal(1), -2)
Decimal('-2')
>>> ExtendedContext.max_mag(1, Decimal(-2))
Decimal('-2')

Definition at line 4743 of file decimal.py.

04743 
04744     def max_mag(self, a, b):
04745         """Compares the values numerically with their sign ignored.
04746 
04747         >>> ExtendedContext.max_mag(Decimal('7'), Decimal('NaN'))
04748         Decimal('7')
04749         >>> ExtendedContext.max_mag(Decimal('7'), Decimal('-10'))
04750         Decimal('-10')
04751         >>> ExtendedContext.max_mag(1, -2)
04752         Decimal('-2')
04753         >>> ExtendedContext.max_mag(Decimal(1), -2)
04754         Decimal('-2')
04755         >>> ExtendedContext.max_mag(1, Decimal(-2))
04756         Decimal('-2')
04757         """
04758         a = _convert_other(a, raiseit=True)
04759         return a.max_mag(b, context=self)

Here is the call graph for this function:

def decimal.Context.min (   self,
  a,
  b 
)
min compares two values numerically and returns the minimum.

If either operand is a NaN then the general rules apply.
Otherwise, the operands are compared as though by the compare
operation.  If they are numerically equal then the left-hand operand
is chosen as the result.  Otherwise the minimum (closer to negative
infinity) of the two operands is chosen as the result.

>>> ExtendedContext.min(Decimal('3'), Decimal('2'))
Decimal('2')
>>> ExtendedContext.min(Decimal('-10'), Decimal('3'))
Decimal('-10')
>>> ExtendedContext.min(Decimal('1.0'), Decimal('1'))
Decimal('1.0')
>>> ExtendedContext.min(Decimal('7'), Decimal('NaN'))
Decimal('7')
>>> ExtendedContext.min(1, 2)
Decimal('1')
>>> ExtendedContext.min(Decimal(1), 2)
Decimal('1')
>>> ExtendedContext.min(1, Decimal(29))
Decimal('1')

Definition at line 4760 of file decimal.py.

04760 
04761     def min(self, a, b):
04762         """min compares two values numerically and returns the minimum.
04763 
04764         If either operand is a NaN then the general rules apply.
04765         Otherwise, the operands are compared as though by the compare
04766         operation.  If they are numerically equal then the left-hand operand
04767         is chosen as the result.  Otherwise the minimum (closer to negative
04768         infinity) of the two operands is chosen as the result.
04769 
04770         >>> ExtendedContext.min(Decimal('3'), Decimal('2'))
04771         Decimal('2')
04772         >>> ExtendedContext.min(Decimal('-10'), Decimal('3'))
04773         Decimal('-10')
04774         >>> ExtendedContext.min(Decimal('1.0'), Decimal('1'))
04775         Decimal('1.0')
04776         >>> ExtendedContext.min(Decimal('7'), Decimal('NaN'))
04777         Decimal('7')
04778         >>> ExtendedContext.min(1, 2)
04779         Decimal('1')
04780         >>> ExtendedContext.min(Decimal(1), 2)
04781         Decimal('1')
04782         >>> ExtendedContext.min(1, Decimal(29))
04783         Decimal('1')
04784         """
04785         a = _convert_other(a, raiseit=True)
04786         return a.min(b, context=self)

Here is the call graph for this function:

def decimal.Context.min_mag (   self,
  a,
  b 
)
Compares the values numerically with their sign ignored.

>>> ExtendedContext.min_mag(Decimal('3'), Decimal('-2'))
Decimal('-2')
>>> ExtendedContext.min_mag(Decimal('-3'), Decimal('NaN'))
Decimal('-3')
>>> ExtendedContext.min_mag(1, -2)
Decimal('1')
>>> ExtendedContext.min_mag(Decimal(1), -2)
Decimal('1')
>>> ExtendedContext.min_mag(1, Decimal(-2))
Decimal('1')

Definition at line 4787 of file decimal.py.

04787 
04788     def min_mag(self, a, b):
04789         """Compares the values numerically with their sign ignored.
04790 
04791         >>> ExtendedContext.min_mag(Decimal('3'), Decimal('-2'))
04792         Decimal('-2')
04793         >>> ExtendedContext.min_mag(Decimal('-3'), Decimal('NaN'))
04794         Decimal('-3')
04795         >>> ExtendedContext.min_mag(1, -2)
04796         Decimal('1')
04797         >>> ExtendedContext.min_mag(Decimal(1), -2)
04798         Decimal('1')
04799         >>> ExtendedContext.min_mag(1, Decimal(-2))
04800         Decimal('1')
04801         """
04802         a = _convert_other(a, raiseit=True)
04803         return a.min_mag(b, context=self)

Here is the call graph for this function:

def decimal.Context.minus (   self,
  a 
)
Minus corresponds to unary prefix minus in Python.

The operation is evaluated using the same rules as subtract; the
operation minus(a) is calculated as subtract('0', a) where the '0'
has the same exponent as the operand.

>>> ExtendedContext.minus(Decimal('1.3'))
Decimal('-1.3')
>>> ExtendedContext.minus(Decimal('-1.3'))
Decimal('1.3')
>>> ExtendedContext.minus(1)
Decimal('-1')

Definition at line 4804 of file decimal.py.

04804 
04805     def minus(self, a):
04806         """Minus corresponds to unary prefix minus in Python.
04807 
04808         The operation is evaluated using the same rules as subtract; the
04809         operation minus(a) is calculated as subtract('0', a) where the '0'
04810         has the same exponent as the operand.
04811 
04812         >>> ExtendedContext.minus(Decimal('1.3'))
04813         Decimal('-1.3')
04814         >>> ExtendedContext.minus(Decimal('-1.3'))
04815         Decimal('1.3')
04816         >>> ExtendedContext.minus(1)
04817         Decimal('-1')
04818         """
04819         a = _convert_other(a, raiseit=True)
04820         return a.__neg__(context=self)

Here is the call graph for this function:

def decimal.Context.multiply (   self,
  a,
  b 
)
multiply multiplies two operands.

If either operand is a special value then the general rules apply.
Otherwise, the operands are multiplied together
('long multiplication'), resulting in a number which may be as long as
the sum of the lengths of the two operands.

>>> ExtendedContext.multiply(Decimal('1.20'), Decimal('3'))
Decimal('3.60')
>>> ExtendedContext.multiply(Decimal('7'), Decimal('3'))
Decimal('21')
>>> ExtendedContext.multiply(Decimal('0.9'), Decimal('0.8'))
Decimal('0.72')
>>> ExtendedContext.multiply(Decimal('0.9'), Decimal('-0'))
Decimal('-0.0')
>>> ExtendedContext.multiply(Decimal('654321'), Decimal('654321'))
Decimal('4.28135971E+11')
>>> ExtendedContext.multiply(7, 7)
Decimal('49')
>>> ExtendedContext.multiply(Decimal(7), 7)
Decimal('49')
>>> ExtendedContext.multiply(7, Decimal(7))
Decimal('49')

Definition at line 4821 of file decimal.py.

04821 
04822     def multiply(self, a, b):
04823         """multiply multiplies two operands.
04824 
04825         If either operand is a special value then the general rules apply.
04826         Otherwise, the operands are multiplied together
04827         ('long multiplication'), resulting in a number which may be as long as
04828         the sum of the lengths of the two operands.
04829 
04830         >>> ExtendedContext.multiply(Decimal('1.20'), Decimal('3'))
04831         Decimal('3.60')
04832         >>> ExtendedContext.multiply(Decimal('7'), Decimal('3'))
04833         Decimal('21')
04834         >>> ExtendedContext.multiply(Decimal('0.9'), Decimal('0.8'))
04835         Decimal('0.72')
04836         >>> ExtendedContext.multiply(Decimal('0.9'), Decimal('-0'))
04837         Decimal('-0.0')
04838         >>> ExtendedContext.multiply(Decimal('654321'), Decimal('654321'))
04839         Decimal('4.28135971E+11')
04840         >>> ExtendedContext.multiply(7, 7)
04841         Decimal('49')
04842         >>> ExtendedContext.multiply(Decimal(7), 7)
04843         Decimal('49')
04844         >>> ExtendedContext.multiply(7, Decimal(7))
04845         Decimal('49')
04846         """
04847         a = _convert_other(a, raiseit=True)
04848         r = a.__mul__(b, context=self)
04849         if r is NotImplemented:
04850             raise TypeError("Unable to convert %s to Decimal" % b)
04851         else:
04852             return r

Here is the call graph for this function:

def decimal.Context.next_minus (   self,
  a 
)
Returns the largest representable number smaller than a.

>>> c = ExtendedContext.copy()
>>> c.Emin = -999
>>> c.Emax = 999
>>> ExtendedContext.next_minus(Decimal('1'))
Decimal('0.999999999')
>>> c.next_minus(Decimal('1E-1007'))
Decimal('0E-1007')
>>> ExtendedContext.next_minus(Decimal('-1.00000003'))
Decimal('-1.00000004')
>>> c.next_minus(Decimal('Infinity'))
Decimal('9.99999999E+999')
>>> c.next_minus(1)
Decimal('0.999999999')

Definition at line 4853 of file decimal.py.

04853 
04854     def next_minus(self, a):
04855         """Returns the largest representable number smaller than a.
04856 
04857         >>> c = ExtendedContext.copy()
04858         >>> c.Emin = -999
04859         >>> c.Emax = 999
04860         >>> ExtendedContext.next_minus(Decimal('1'))
04861         Decimal('0.999999999')
04862         >>> c.next_minus(Decimal('1E-1007'))
04863         Decimal('0E-1007')
04864         >>> ExtendedContext.next_minus(Decimal('-1.00000003'))
04865         Decimal('-1.00000004')
04866         >>> c.next_minus(Decimal('Infinity'))
04867         Decimal('9.99999999E+999')
04868         >>> c.next_minus(1)
04869         Decimal('0.999999999')
04870         """
04871         a = _convert_other(a, raiseit=True)
04872         return a.next_minus(context=self)

Here is the call graph for this function:

def decimal.Context.next_plus (   self,
  a 
)
Returns the smallest representable number larger than a.

>>> c = ExtendedContext.copy()
>>> c.Emin = -999
>>> c.Emax = 999
>>> ExtendedContext.next_plus(Decimal('1'))
Decimal('1.00000001')
>>> c.next_plus(Decimal('-1E-1007'))
Decimal('-0E-1007')
>>> ExtendedContext.next_plus(Decimal('-1.00000003'))
Decimal('-1.00000002')
>>> c.next_plus(Decimal('-Infinity'))
Decimal('-9.99999999E+999')
>>> c.next_plus(1)
Decimal('1.00000001')

Definition at line 4873 of file decimal.py.

04873 
04874     def next_plus(self, a):
04875         """Returns the smallest representable number larger than a.
04876 
04877         >>> c = ExtendedContext.copy()
04878         >>> c.Emin = -999
04879         >>> c.Emax = 999
04880         >>> ExtendedContext.next_plus(Decimal('1'))
04881         Decimal('1.00000001')
04882         >>> c.next_plus(Decimal('-1E-1007'))
04883         Decimal('-0E-1007')
04884         >>> ExtendedContext.next_plus(Decimal('-1.00000003'))
04885         Decimal('-1.00000002')
04886         >>> c.next_plus(Decimal('-Infinity'))
04887         Decimal('-9.99999999E+999')
04888         >>> c.next_plus(1)
04889         Decimal('1.00000001')
04890         """
04891         a = _convert_other(a, raiseit=True)
04892         return a.next_plus(context=self)

Here is the call graph for this function:

def decimal.Context.next_toward (   self,
  a,
  b 
)
Returns the number closest to a, in direction towards b.

The result is the closest representable number from the first
operand (but not the first operand) that is in the direction
towards the second operand, unless the operands have the same
value.

>>> c = ExtendedContext.copy()
>>> c.Emin = -999
>>> c.Emax = 999
>>> c.next_toward(Decimal('1'), Decimal('2'))
Decimal('1.00000001')
>>> c.next_toward(Decimal('-1E-1007'), Decimal('1'))
Decimal('-0E-1007')
>>> c.next_toward(Decimal('-1.00000003'), Decimal('0'))
Decimal('-1.00000002')
>>> c.next_toward(Decimal('1'), Decimal('0'))
Decimal('0.999999999')
>>> c.next_toward(Decimal('1E-1007'), Decimal('-100'))
Decimal('0E-1007')
>>> c.next_toward(Decimal('-1.00000003'), Decimal('-10'))
Decimal('-1.00000004')
>>> c.next_toward(Decimal('0.00'), Decimal('-0.0000'))
Decimal('-0.00')
>>> c.next_toward(0, 1)
Decimal('1E-1007')
>>> c.next_toward(Decimal(0), 1)
Decimal('1E-1007')
>>> c.next_toward(0, Decimal(1))
Decimal('1E-1007')

Definition at line 4893 of file decimal.py.

04893 
04894     def next_toward(self, a, b):
04895         """Returns the number closest to a, in direction towards b.
04896 
04897         The result is the closest representable number from the first
04898         operand (but not the first operand) that is in the direction
04899         towards the second operand, unless the operands have the same
04900         value.
04901 
04902         >>> c = ExtendedContext.copy()
04903         >>> c.Emin = -999
04904         >>> c.Emax = 999
04905         >>> c.next_toward(Decimal('1'), Decimal('2'))
04906         Decimal('1.00000001')
04907         >>> c.next_toward(Decimal('-1E-1007'), Decimal('1'))
04908         Decimal('-0E-1007')
04909         >>> c.next_toward(Decimal('-1.00000003'), Decimal('0'))
04910         Decimal('-1.00000002')
04911         >>> c.next_toward(Decimal('1'), Decimal('0'))
04912         Decimal('0.999999999')
04913         >>> c.next_toward(Decimal('1E-1007'), Decimal('-100'))
04914         Decimal('0E-1007')
04915         >>> c.next_toward(Decimal('-1.00000003'), Decimal('-10'))
04916         Decimal('-1.00000004')
04917         >>> c.next_toward(Decimal('0.00'), Decimal('-0.0000'))
04918         Decimal('-0.00')
04919         >>> c.next_toward(0, 1)
04920         Decimal('1E-1007')
04921         >>> c.next_toward(Decimal(0), 1)
04922         Decimal('1E-1007')
04923         >>> c.next_toward(0, Decimal(1))
04924         Decimal('1E-1007')
04925         """
04926         a = _convert_other(a, raiseit=True)
04927         return a.next_toward(b, context=self)

Here is the call graph for this function:

def decimal.Context.normalize (   self,
  a 
)
normalize reduces an operand to its simplest form.

Essentially a plus operation with all trailing zeros removed from the
result.

>>> ExtendedContext.normalize(Decimal('2.1'))
Decimal('2.1')
>>> ExtendedContext.normalize(Decimal('-2.0'))
Decimal('-2')
>>> ExtendedContext.normalize(Decimal('1.200'))
Decimal('1.2')
>>> ExtendedContext.normalize(Decimal('-120'))
Decimal('-1.2E+2')
>>> ExtendedContext.normalize(Decimal('120.00'))
Decimal('1.2E+2')
>>> ExtendedContext.normalize(Decimal('0.00'))
Decimal('0')
>>> ExtendedContext.normalize(6)
Decimal('6')

Definition at line 4928 of file decimal.py.

04928 
04929     def normalize(self, a):
04930         """normalize reduces an operand to its simplest form.
04931 
04932         Essentially a plus operation with all trailing zeros removed from the
04933         result.
04934 
04935         >>> ExtendedContext.normalize(Decimal('2.1'))
04936         Decimal('2.1')
04937         >>> ExtendedContext.normalize(Decimal('-2.0'))
04938         Decimal('-2')
04939         >>> ExtendedContext.normalize(Decimal('1.200'))
04940         Decimal('1.2')
04941         >>> ExtendedContext.normalize(Decimal('-120'))
04942         Decimal('-1.2E+2')
04943         >>> ExtendedContext.normalize(Decimal('120.00'))
04944         Decimal('1.2E+2')
04945         >>> ExtendedContext.normalize(Decimal('0.00'))
04946         Decimal('0')
04947         >>> ExtendedContext.normalize(6)
04948         Decimal('6')
04949         """
04950         a = _convert_other(a, raiseit=True)
04951         return a.normalize(context=self)

Here is the call graph for this function:

def decimal.Context.number_class (   self,
  a 
)
Returns an indication of the class of the operand.

The class is one of the following strings:
  -sNaN
  -NaN
  -Infinity
  -Normal
  -Subnormal
  -Zero
  +Zero
  +Subnormal
  +Normal
  +Infinity

>>> c = Context(ExtendedContext)
>>> c.Emin = -999
>>> c.Emax = 999
>>> c.number_class(Decimal('Infinity'))
'+Infinity'
>>> c.number_class(Decimal('1E-10'))
'+Normal'
>>> c.number_class(Decimal('2.50'))
'+Normal'
>>> c.number_class(Decimal('0.1E-999'))
'+Subnormal'
>>> c.number_class(Decimal('0'))
'+Zero'
>>> c.number_class(Decimal('-0'))
'-Zero'
>>> c.number_class(Decimal('-0.1E-999'))
'-Subnormal'
>>> c.number_class(Decimal('-1E-10'))
'-Normal'
>>> c.number_class(Decimal('-2.50'))
'-Normal'
>>> c.number_class(Decimal('-Infinity'))
'-Infinity'
>>> c.number_class(Decimal('NaN'))
'NaN'
>>> c.number_class(Decimal('-NaN'))
'NaN'
>>> c.number_class(Decimal('sNaN'))
'sNaN'
>>> c.number_class(123)
'+Normal'

Definition at line 4952 of file decimal.py.

04952 
04953     def number_class(self, a):
04954         """Returns an indication of the class of the operand.
04955 
04956         The class is one of the following strings:
04957           -sNaN
04958           -NaN
04959           -Infinity
04960           -Normal
04961           -Subnormal
04962           -Zero
04963           +Zero
04964           +Subnormal
04965           +Normal
04966           +Infinity
04967 
04968         >>> c = Context(ExtendedContext)
04969         >>> c.Emin = -999
04970         >>> c.Emax = 999
04971         >>> c.number_class(Decimal('Infinity'))
04972         '+Infinity'
04973         >>> c.number_class(Decimal('1E-10'))
04974         '+Normal'
04975         >>> c.number_class(Decimal('2.50'))
04976         '+Normal'
04977         >>> c.number_class(Decimal('0.1E-999'))
04978         '+Subnormal'
04979         >>> c.number_class(Decimal('0'))
04980         '+Zero'
04981         >>> c.number_class(Decimal('-0'))
04982         '-Zero'
04983         >>> c.number_class(Decimal('-0.1E-999'))
04984         '-Subnormal'
04985         >>> c.number_class(Decimal('-1E-10'))
04986         '-Normal'
04987         >>> c.number_class(Decimal('-2.50'))
04988         '-Normal'
04989         >>> c.number_class(Decimal('-Infinity'))
04990         '-Infinity'
04991         >>> c.number_class(Decimal('NaN'))
04992         'NaN'
04993         >>> c.number_class(Decimal('-NaN'))
04994         'NaN'
04995         >>> c.number_class(Decimal('sNaN'))
04996         'sNaN'
04997         >>> c.number_class(123)
04998         '+Normal'
04999         """
05000         a = _convert_other(a, raiseit=True)
05001         return a.number_class(context=self)

Here is the call graph for this function:

def decimal.Context.plus (   self,
  a 
)
Plus corresponds to unary prefix plus in Python.

The operation is evaluated using the same rules as add; the
operation plus(a) is calculated as add('0', a) where the '0'
has the same exponent as the operand.

>>> ExtendedContext.plus(Decimal('1.3'))
Decimal('1.3')
>>> ExtendedContext.plus(Decimal('-1.3'))
Decimal('-1.3')
>>> ExtendedContext.plus(-1)
Decimal('-1')

Definition at line 5002 of file decimal.py.

05002 
05003     def plus(self, a):
05004         """Plus corresponds to unary prefix plus in Python.
05005 
05006         The operation is evaluated using the same rules as add; the
05007         operation plus(a) is calculated as add('0', a) where the '0'
05008         has the same exponent as the operand.
05009 
05010         >>> ExtendedContext.plus(Decimal('1.3'))
05011         Decimal('1.3')
05012         >>> ExtendedContext.plus(Decimal('-1.3'))
05013         Decimal('-1.3')
05014         >>> ExtendedContext.plus(-1)
05015         Decimal('-1')
05016         """
05017         a = _convert_other(a, raiseit=True)
05018         return a.__pos__(context=self)

Here is the call graph for this function:

def decimal.Context.power (   self,
  a,
  b,
  modulo = None 
)
Raises a to the power of b, to modulo if given.

With two arguments, compute a**b.  If a is negative then b
must be integral.  The result will be inexact unless b is
integral and the result is finite and can be expressed exactly
in 'precision' digits.

With three arguments, compute (a**b) % modulo.  For the
three argument form, the following restrictions on the
arguments hold:

 - all three arguments must be integral
 - b must be nonnegative
 - at least one of a or b must be nonzero
 - modulo must be nonzero and have at most 'precision' digits

The result of pow(a, b, modulo) is identical to the result
that would be obtained by computing (a**b) % modulo with
unbounded precision, but is computed more efficiently.  It is
always exact.

>>> c = ExtendedContext.copy()
>>> c.Emin = -999
>>> c.Emax = 999
>>> c.power(Decimal('2'), Decimal('3'))
Decimal('8')
>>> c.power(Decimal('-2'), Decimal('3'))
Decimal('-8')
>>> c.power(Decimal('2'), Decimal('-3'))
Decimal('0.125')
>>> c.power(Decimal('1.7'), Decimal('8'))
Decimal('69.7575744')
>>> c.power(Decimal('10'), Decimal('0.301029996'))
Decimal('2.00000000')
>>> c.power(Decimal('Infinity'), Decimal('-1'))
Decimal('0')
>>> c.power(Decimal('Infinity'), Decimal('0'))
Decimal('1')
>>> c.power(Decimal('Infinity'), Decimal('1'))
Decimal('Infinity')
>>> c.power(Decimal('-Infinity'), Decimal('-1'))
Decimal('-0')
>>> c.power(Decimal('-Infinity'), Decimal('0'))
Decimal('1')
>>> c.power(Decimal('-Infinity'), Decimal('1'))
Decimal('-Infinity')
>>> c.power(Decimal('-Infinity'), Decimal('2'))
Decimal('Infinity')
>>> c.power(Decimal('0'), Decimal('0'))
Decimal('NaN')

>>> c.power(Decimal('3'), Decimal('7'), Decimal('16'))
Decimal('11')
>>> c.power(Decimal('-3'), Decimal('7'), Decimal('16'))
Decimal('-11')
>>> c.power(Decimal('-3'), Decimal('8'), Decimal('16'))
Decimal('1')
>>> c.power(Decimal('3'), Decimal('7'), Decimal('-16'))
Decimal('11')
>>> c.power(Decimal('23E12345'), Decimal('67E189'), Decimal('123456789'))
Decimal('11729830')
>>> c.power(Decimal('-0'), Decimal('17'), Decimal('1729'))
Decimal('-0')
>>> c.power(Decimal('-23'), Decimal('0'), Decimal('65537'))
Decimal('1')
>>> ExtendedContext.power(7, 7)
Decimal('823543')
>>> ExtendedContext.power(Decimal(7), 7)
Decimal('823543')
>>> ExtendedContext.power(7, Decimal(7), 2)
Decimal('1')

Definition at line 5019 of file decimal.py.

05019 
05020     def power(self, a, b, modulo=None):
05021         """Raises a to the power of b, to modulo if given.
05022 
05023         With two arguments, compute a**b.  If a is negative then b
05024         must be integral.  The result will be inexact unless b is
05025         integral and the result is finite and can be expressed exactly
05026         in 'precision' digits.
05027 
05028         With three arguments, compute (a**b) % modulo.  For the
05029         three argument form, the following restrictions on the
05030         arguments hold:
05031 
05032          - all three arguments must be integral
05033          - b must be nonnegative
05034          - at least one of a or b must be nonzero
05035          - modulo must be nonzero and have at most 'precision' digits
05036 
05037         The result of pow(a, b, modulo) is identical to the result
05038         that would be obtained by computing (a**b) % modulo with
05039         unbounded precision, but is computed more efficiently.  It is
05040         always exact.
05041 
05042         >>> c = ExtendedContext.copy()
05043         >>> c.Emin = -999
05044         >>> c.Emax = 999
05045         >>> c.power(Decimal('2'), Decimal('3'))
05046         Decimal('8')
05047         >>> c.power(Decimal('-2'), Decimal('3'))
05048         Decimal('-8')
05049         >>> c.power(Decimal('2'), Decimal('-3'))
05050         Decimal('0.125')
05051         >>> c.power(Decimal('1.7'), Decimal('8'))
05052         Decimal('69.7575744')
05053         >>> c.power(Decimal('10'), Decimal('0.301029996'))
05054         Decimal('2.00000000')
05055         >>> c.power(Decimal('Infinity'), Decimal('-1'))
05056         Decimal('0')
05057         >>> c.power(Decimal('Infinity'), Decimal('0'))
05058         Decimal('1')
05059         >>> c.power(Decimal('Infinity'), Decimal('1'))
05060         Decimal('Infinity')
05061         >>> c.power(Decimal('-Infinity'), Decimal('-1'))
05062         Decimal('-0')
05063         >>> c.power(Decimal('-Infinity'), Decimal('0'))
05064         Decimal('1')
05065         >>> c.power(Decimal('-Infinity'), Decimal('1'))
05066         Decimal('-Infinity')
05067         >>> c.power(Decimal('-Infinity'), Decimal('2'))
05068         Decimal('Infinity')
05069         >>> c.power(Decimal('0'), Decimal('0'))
05070         Decimal('NaN')
05071 
05072         >>> c.power(Decimal('3'), Decimal('7'), Decimal('16'))
05073         Decimal('11')
05074         >>> c.power(Decimal('-3'), Decimal('7'), Decimal('16'))
05075         Decimal('-11')
05076         >>> c.power(Decimal('-3'), Decimal('8'), Decimal('16'))
05077         Decimal('1')
05078         >>> c.power(Decimal('3'), Decimal('7'), Decimal('-16'))
05079         Decimal('11')
05080         >>> c.power(Decimal('23E12345'), Decimal('67E189'), Decimal('123456789'))
05081         Decimal('11729830')
05082         >>> c.power(Decimal('-0'), Decimal('17'), Decimal('1729'))
05083         Decimal('-0')
05084         >>> c.power(Decimal('-23'), Decimal('0'), Decimal('65537'))
05085         Decimal('1')
05086         >>> ExtendedContext.power(7, 7)
05087         Decimal('823543')
05088         >>> ExtendedContext.power(Decimal(7), 7)
05089         Decimal('823543')
05090         >>> ExtendedContext.power(7, Decimal(7), 2)
05091         Decimal('1')
05092         """
05093         a = _convert_other(a, raiseit=True)
05094         r = a.__pow__(b, modulo, context=self)
05095         if r is NotImplemented:
05096             raise TypeError("Unable to convert %s to Decimal" % b)
05097         else:
05098             return r

Here is the call graph for this function:

def decimal.Context.quantize (   self,
  a,
  b 
)
Returns a value equal to 'a' (rounded), having the exponent of 'b'.

The coefficient of the result is derived from that of the left-hand
operand.  It may be rounded using the current rounding setting (if the
exponent is being increased), multiplied by a positive power of ten (if
the exponent is being decreased), or is unchanged (if the exponent is
already equal to that of the right-hand operand).

Unlike other operations, if the length of the coefficient after the
quantize operation would be greater than precision then an Invalid
operation condition is raised.  This guarantees that, unless there is
an error condition, the exponent of the result of a quantize is always
equal to that of the right-hand operand.

Also unlike other operations, quantize will never raise Underflow, even
if the result is subnormal and inexact.

>>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.001'))
Decimal('2.170')
>>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.01'))
Decimal('2.17')
>>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.1'))
Decimal('2.2')
>>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+0'))
Decimal('2')
>>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+1'))
Decimal('0E+1')
>>> ExtendedContext.quantize(Decimal('-Inf'), Decimal('Infinity'))
Decimal('-Infinity')
>>> ExtendedContext.quantize(Decimal('2'), Decimal('Infinity'))
Decimal('NaN')
>>> ExtendedContext.quantize(Decimal('-0.1'), Decimal('1'))
Decimal('-0')
>>> ExtendedContext.quantize(Decimal('-0'), Decimal('1e+5'))
Decimal('-0E+5')
>>> ExtendedContext.quantize(Decimal('+35236450.6'), Decimal('1e-2'))
Decimal('NaN')
>>> ExtendedContext.quantize(Decimal('-35236450.6'), Decimal('1e-2'))
Decimal('NaN')
>>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-1'))
Decimal('217.0')
>>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-0'))
Decimal('217')
>>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+1'))
Decimal('2.2E+2')
>>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+2'))
Decimal('2E+2')
>>> ExtendedContext.quantize(1, 2)
Decimal('1')
>>> ExtendedContext.quantize(Decimal(1), 2)
Decimal('1')
>>> ExtendedContext.quantize(1, Decimal(2))
Decimal('1')

Definition at line 5099 of file decimal.py.

05099 
05100     def quantize(self, a, b):
05101         """Returns a value equal to 'a' (rounded), having the exponent of 'b'.
05102 
05103         The coefficient of the result is derived from that of the left-hand
05104         operand.  It may be rounded using the current rounding setting (if the
05105         exponent is being increased), multiplied by a positive power of ten (if
05106         the exponent is being decreased), or is unchanged (if the exponent is
05107         already equal to that of the right-hand operand).
05108 
05109         Unlike other operations, if the length of the coefficient after the
05110         quantize operation would be greater than precision then an Invalid
05111         operation condition is raised.  This guarantees that, unless there is
05112         an error condition, the exponent of the result of a quantize is always
05113         equal to that of the right-hand operand.
05114 
05115         Also unlike other operations, quantize will never raise Underflow, even
05116         if the result is subnormal and inexact.
05117 
05118         >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.001'))
05119         Decimal('2.170')
05120         >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.01'))
05121         Decimal('2.17')
05122         >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.1'))
05123         Decimal('2.2')
05124         >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+0'))
05125         Decimal('2')
05126         >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+1'))
05127         Decimal('0E+1')
05128         >>> ExtendedContext.quantize(Decimal('-Inf'), Decimal('Infinity'))
05129         Decimal('-Infinity')
05130         >>> ExtendedContext.quantize(Decimal('2'), Decimal('Infinity'))
05131         Decimal('NaN')
05132         >>> ExtendedContext.quantize(Decimal('-0.1'), Decimal('1'))
05133         Decimal('-0')
05134         >>> ExtendedContext.quantize(Decimal('-0'), Decimal('1e+5'))
05135         Decimal('-0E+5')
05136         >>> ExtendedContext.quantize(Decimal('+35236450.6'), Decimal('1e-2'))
05137         Decimal('NaN')
05138         >>> ExtendedContext.quantize(Decimal('-35236450.6'), Decimal('1e-2'))
05139         Decimal('NaN')
05140         >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-1'))
05141         Decimal('217.0')
05142         >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-0'))
05143         Decimal('217')
05144         >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+1'))
05145         Decimal('2.2E+2')
05146         >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+2'))
05147         Decimal('2E+2')
05148         >>> ExtendedContext.quantize(1, 2)
05149         Decimal('1')
05150         >>> ExtendedContext.quantize(Decimal(1), 2)
05151         Decimal('1')
05152         >>> ExtendedContext.quantize(1, Decimal(2))
05153         Decimal('1')
05154         """
05155         a = _convert_other(a, raiseit=True)
05156         return a.quantize(b, context=self)

Here is the call graph for this function:

def decimal.Context.radix (   self)
Just returns 10, as this is Decimal, :)

>>> ExtendedContext.radix()
Decimal('10')

Definition at line 5157 of file decimal.py.

05157 
05158     def radix(self):
05159         """Just returns 10, as this is Decimal, :)
05160 
05161         >>> ExtendedContext.radix()
05162         Decimal('10')
05163         """
05164         return Decimal(10)

def decimal.Context.remainder (   self,
  a,
  b 
)
Returns the remainder from integer division.

The result is the residue of the dividend after the operation of
calculating integer division as described for divide-integer, rounded
to precision digits if necessary.  The sign of the result, if
non-zero, is the same as that of the original dividend.

This operation will fail under the same conditions as integer division
(that is, if integer division on the same two operands would fail, the
remainder cannot be calculated).

>>> ExtendedContext.remainder(Decimal('2.1'), Decimal('3'))
Decimal('2.1')
>>> ExtendedContext.remainder(Decimal('10'), Decimal('3'))
Decimal('1')
>>> ExtendedContext.remainder(Decimal('-10'), Decimal('3'))
Decimal('-1')
>>> ExtendedContext.remainder(Decimal('10.2'), Decimal('1'))
Decimal('0.2')
>>> ExtendedContext.remainder(Decimal('10'), Decimal('0.3'))
Decimal('0.1')
>>> ExtendedContext.remainder(Decimal('3.6'), Decimal('1.3'))
Decimal('1.0')
>>> ExtendedContext.remainder(22, 6)
Decimal('4')
>>> ExtendedContext.remainder(Decimal(22), 6)
Decimal('4')
>>> ExtendedContext.remainder(22, Decimal(6))
Decimal('4')

Definition at line 5165 of file decimal.py.

05165 
05166     def remainder(self, a, b):
05167         """Returns the remainder from integer division.
05168 
05169         The result is the residue of the dividend after the operation of
05170         calculating integer division as described for divide-integer, rounded
05171         to precision digits if necessary.  The sign of the result, if
05172         non-zero, is the same as that of the original dividend.
05173 
05174         This operation will fail under the same conditions as integer division
05175         (that is, if integer division on the same two operands would fail, the
05176         remainder cannot be calculated).
05177 
05178         >>> ExtendedContext.remainder(Decimal('2.1'), Decimal('3'))
05179         Decimal('2.1')
05180         >>> ExtendedContext.remainder(Decimal('10'), Decimal('3'))
05181         Decimal('1')
05182         >>> ExtendedContext.remainder(Decimal('-10'), Decimal('3'))
05183         Decimal('-1')
05184         >>> ExtendedContext.remainder(Decimal('10.2'), Decimal('1'))
05185         Decimal('0.2')
05186         >>> ExtendedContext.remainder(Decimal('10'), Decimal('0.3'))
05187         Decimal('0.1')
05188         >>> ExtendedContext.remainder(Decimal('3.6'), Decimal('1.3'))
05189         Decimal('1.0')
05190         >>> ExtendedContext.remainder(22, 6)
05191         Decimal('4')
05192         >>> ExtendedContext.remainder(Decimal(22), 6)
05193         Decimal('4')
05194         >>> ExtendedContext.remainder(22, Decimal(6))
05195         Decimal('4')
05196         """
05197         a = _convert_other(a, raiseit=True)
05198         r = a.__mod__(b, context=self)
05199         if r is NotImplemented:
05200             raise TypeError("Unable to convert %s to Decimal" % b)
05201         else:
05202             return r

Here is the call graph for this function:

def decimal.Context.remainder_near (   self,
  a,
  b 
)
Returns to be "a - b * n", where n is the integer nearest the exact
value of "x / b" (if two integers are equally near then the even one
is chosen).  If the result is equal to 0 then its sign will be the
sign of a.

This operation will fail under the same conditions as integer division
(that is, if integer division on the same two operands would fail, the
remainder cannot be calculated).

>>> ExtendedContext.remainder_near(Decimal('2.1'), Decimal('3'))
Decimal('-0.9')
>>> ExtendedContext.remainder_near(Decimal('10'), Decimal('6'))
Decimal('-2')
>>> ExtendedContext.remainder_near(Decimal('10'), Decimal('3'))
Decimal('1')
>>> ExtendedContext.remainder_near(Decimal('-10'), Decimal('3'))
Decimal('-1')
>>> ExtendedContext.remainder_near(Decimal('10.2'), Decimal('1'))
Decimal('0.2')
>>> ExtendedContext.remainder_near(Decimal('10'), Decimal('0.3'))
Decimal('0.1')
>>> ExtendedContext.remainder_near(Decimal('3.6'), Decimal('1.3'))
Decimal('-0.3')
>>> ExtendedContext.remainder_near(3, 11)
Decimal('3')
>>> ExtendedContext.remainder_near(Decimal(3), 11)
Decimal('3')
>>> ExtendedContext.remainder_near(3, Decimal(11))
Decimal('3')

Definition at line 5203 of file decimal.py.

05203 
05204     def remainder_near(self, a, b):
05205         """Returns to be "a - b * n", where n is the integer nearest the exact
05206         value of "x / b" (if two integers are equally near then the even one
05207         is chosen).  If the result is equal to 0 then its sign will be the
05208         sign of a.
05209 
05210         This operation will fail under the same conditions as integer division
05211         (that is, if integer division on the same two operands would fail, the
05212         remainder cannot be calculated).
05213 
05214         >>> ExtendedContext.remainder_near(Decimal('2.1'), Decimal('3'))
05215         Decimal('-0.9')
05216         >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('6'))
05217         Decimal('-2')
05218         >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('3'))
05219         Decimal('1')
05220         >>> ExtendedContext.remainder_near(Decimal('-10'), Decimal('3'))
05221         Decimal('-1')
05222         >>> ExtendedContext.remainder_near(Decimal('10.2'), Decimal('1'))
05223         Decimal('0.2')
05224         >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('0.3'))
05225         Decimal('0.1')
05226         >>> ExtendedContext.remainder_near(Decimal('3.6'), Decimal('1.3'))
05227         Decimal('-0.3')
05228         >>> ExtendedContext.remainder_near(3, 11)
05229         Decimal('3')
05230         >>> ExtendedContext.remainder_near(Decimal(3), 11)
05231         Decimal('3')
05232         >>> ExtendedContext.remainder_near(3, Decimal(11))
05233         Decimal('3')
05234         """
05235         a = _convert_other(a, raiseit=True)
05236         return a.remainder_near(b, context=self)

Here is the call graph for this function:

def decimal.Context.rotate (   self,
  a,
  b 
)
Returns a rotated copy of a, b times.

The coefficient of the result is a rotated copy of the digits in
the coefficient of the first operand.  The number of places of
rotation is taken from the absolute value of the second operand,
with the rotation being to the left if the second operand is
positive or to the right otherwise.

>>> ExtendedContext.rotate(Decimal('34'), Decimal('8'))
Decimal('400000003')
>>> ExtendedContext.rotate(Decimal('12'), Decimal('9'))
Decimal('12')
>>> ExtendedContext.rotate(Decimal('123456789'), Decimal('-2'))
Decimal('891234567')
>>> ExtendedContext.rotate(Decimal('123456789'), Decimal('0'))
Decimal('123456789')
>>> ExtendedContext.rotate(Decimal('123456789'), Decimal('+2'))
Decimal('345678912')
>>> ExtendedContext.rotate(1333333, 1)
Decimal('13333330')
>>> ExtendedContext.rotate(Decimal(1333333), 1)
Decimal('13333330')
>>> ExtendedContext.rotate(1333333, Decimal(1))
Decimal('13333330')

Definition at line 5237 of file decimal.py.

05237 
05238     def rotate(self, a, b):
05239         """Returns a rotated copy of a, b times.
05240 
05241         The coefficient of the result is a rotated copy of the digits in
05242         the coefficient of the first operand.  The number of places of
05243         rotation is taken from the absolute value of the second operand,
05244         with the rotation being to the left if the second operand is
05245         positive or to the right otherwise.
05246 
05247         >>> ExtendedContext.rotate(Decimal('34'), Decimal('8'))
05248         Decimal('400000003')
05249         >>> ExtendedContext.rotate(Decimal('12'), Decimal('9'))
05250         Decimal('12')
05251         >>> ExtendedContext.rotate(Decimal('123456789'), Decimal('-2'))
05252         Decimal('891234567')
05253         >>> ExtendedContext.rotate(Decimal('123456789'), Decimal('0'))
05254         Decimal('123456789')
05255         >>> ExtendedContext.rotate(Decimal('123456789'), Decimal('+2'))
05256         Decimal('345678912')
05257         >>> ExtendedContext.rotate(1333333, 1)
05258         Decimal('13333330')
05259         >>> ExtendedContext.rotate(Decimal(1333333), 1)
05260         Decimal('13333330')
05261         >>> ExtendedContext.rotate(1333333, Decimal(1))
05262         Decimal('13333330')
05263         """
05264         a = _convert_other(a, raiseit=True)
05265         return a.rotate(b, context=self)

Here is the call graph for this function:

def decimal.Context.same_quantum (   self,
  a,
  b 
)
Returns True if the two operands have the same exponent.

The result is never affected by either the sign or the coefficient of
either operand.

>>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.001'))
False
>>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.01'))
True
>>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('1'))
False
>>> ExtendedContext.same_quantum(Decimal('Inf'), Decimal('-Inf'))
True
>>> ExtendedContext.same_quantum(10000, -1)
True
>>> ExtendedContext.same_quantum(Decimal(10000), -1)
True
>>> ExtendedContext.same_quantum(10000, Decimal(-1))
True

Definition at line 5266 of file decimal.py.

05266 
05267     def same_quantum(self, a, b):
05268         """Returns True if the two operands have the same exponent.
05269 
05270         The result is never affected by either the sign or the coefficient of
05271         either operand.
05272 
05273         >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.001'))
05274         False
05275         >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.01'))
05276         True
05277         >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('1'))
05278         False
05279         >>> ExtendedContext.same_quantum(Decimal('Inf'), Decimal('-Inf'))
05280         True
05281         >>> ExtendedContext.same_quantum(10000, -1)
05282         True
05283         >>> ExtendedContext.same_quantum(Decimal(10000), -1)
05284         True
05285         >>> ExtendedContext.same_quantum(10000, Decimal(-1))
05286         True
05287         """
05288         a = _convert_other(a, raiseit=True)
05289         return a.same_quantum(b)

Here is the call graph for this function:

def decimal.Context.scaleb (   self,
  a,
  b 
)
Returns the first operand after adding the second value its exp.

>>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('-2'))
Decimal('0.0750')
>>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('0'))
Decimal('7.50')
>>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('3'))
Decimal('7.50E+3')
>>> ExtendedContext.scaleb(1, 4)
Decimal('1E+4')
>>> ExtendedContext.scaleb(Decimal(1), 4)
Decimal('1E+4')
>>> ExtendedContext.scaleb(1, Decimal(4))
Decimal('1E+4')

Definition at line 5290 of file decimal.py.

05290 
05291     def scaleb (self, a, b):
05292         """Returns the first operand after adding the second value its exp.
05293 
05294         >>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('-2'))
05295         Decimal('0.0750')
05296         >>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('0'))
05297         Decimal('7.50')
05298         >>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('3'))
05299         Decimal('7.50E+3')
05300         >>> ExtendedContext.scaleb(1, 4)
05301         Decimal('1E+4')
05302         >>> ExtendedContext.scaleb(Decimal(1), 4)
05303         Decimal('1E+4')
05304         >>> ExtendedContext.scaleb(1, Decimal(4))
05305         Decimal('1E+4')
05306         """
05307         a = _convert_other(a, raiseit=True)
05308         return a.scaleb(b, context=self)

Here is the call graph for this function:

def decimal.Context.shift (   self,
  a,
  b 
)
Returns a shifted copy of a, b times.

The coefficient of the result is a shifted copy of the digits
in the coefficient of the first operand.  The number of places
to shift is taken from the absolute value of the second operand,
with the shift being to the left if the second operand is
positive or to the right otherwise.  Digits shifted into the
coefficient are zeros.

>>> ExtendedContext.shift(Decimal('34'), Decimal('8'))
Decimal('400000000')
>>> ExtendedContext.shift(Decimal('12'), Decimal('9'))
Decimal('0')
>>> ExtendedContext.shift(Decimal('123456789'), Decimal('-2'))
Decimal('1234567')
>>> ExtendedContext.shift(Decimal('123456789'), Decimal('0'))
Decimal('123456789')
>>> ExtendedContext.shift(Decimal('123456789'), Decimal('+2'))
Decimal('345678900')
>>> ExtendedContext.shift(88888888, 2)
Decimal('888888800')
>>> ExtendedContext.shift(Decimal(88888888), 2)
Decimal('888888800')
>>> ExtendedContext.shift(88888888, Decimal(2))
Decimal('888888800')

Definition at line 5309 of file decimal.py.

05309 
05310     def shift(self, a, b):
05311         """Returns a shifted copy of a, b times.
05312 
05313         The coefficient of the result is a shifted copy of the digits
05314         in the coefficient of the first operand.  The number of places
05315         to shift is taken from the absolute value of the second operand,
05316         with the shift being to the left if the second operand is
05317         positive or to the right otherwise.  Digits shifted into the
05318         coefficient are zeros.
05319 
05320         >>> ExtendedContext.shift(Decimal('34'), Decimal('8'))
05321         Decimal('400000000')
05322         >>> ExtendedContext.shift(Decimal('12'), Decimal('9'))
05323         Decimal('0')
05324         >>> ExtendedContext.shift(Decimal('123456789'), Decimal('-2'))
05325         Decimal('1234567')
05326         >>> ExtendedContext.shift(Decimal('123456789'), Decimal('0'))
05327         Decimal('123456789')
05328         >>> ExtendedContext.shift(Decimal('123456789'), Decimal('+2'))
05329         Decimal('345678900')
05330         >>> ExtendedContext.shift(88888888, 2)
05331         Decimal('888888800')
05332         >>> ExtendedContext.shift(Decimal(88888888), 2)
05333         Decimal('888888800')
05334         >>> ExtendedContext.shift(88888888, Decimal(2))
05335         Decimal('888888800')
05336         """
05337         a = _convert_other(a, raiseit=True)
05338         return a.shift(b, context=self)

Here is the call graph for this function:

Here is the caller graph for this function:

def decimal.Context.sqrt (   self,
  a 
)
Square root of a non-negative number to context precision.

If the result must be inexact, it is rounded using the round-half-even
algorithm.

>>> ExtendedContext.sqrt(Decimal('0'))
Decimal('0')
>>> ExtendedContext.sqrt(Decimal('-0'))
Decimal('-0')
>>> ExtendedContext.sqrt(Decimal('0.39'))
Decimal('0.624499800')
>>> ExtendedContext.sqrt(Decimal('100'))
Decimal('10')
>>> ExtendedContext.sqrt(Decimal('1'))
Decimal('1')
>>> ExtendedContext.sqrt(Decimal('1.0'))
Decimal('1.0')
>>> ExtendedContext.sqrt(Decimal('1.00'))
Decimal('1.0')
>>> ExtendedContext.sqrt(Decimal('7'))
Decimal('2.64575131')
>>> ExtendedContext.sqrt(Decimal('10'))
Decimal('3.16227766')
>>> ExtendedContext.sqrt(2)
Decimal('1.41421356')
>>> ExtendedContext.prec
9

Definition at line 5339 of file decimal.py.

05339 
05340     def sqrt(self, a):
05341         """Square root of a non-negative number to context precision.
05342 
05343         If the result must be inexact, it is rounded using the round-half-even
05344         algorithm.
05345 
05346         >>> ExtendedContext.sqrt(Decimal('0'))
05347         Decimal('0')
05348         >>> ExtendedContext.sqrt(Decimal('-0'))
05349         Decimal('-0')
05350         >>> ExtendedContext.sqrt(Decimal('0.39'))
05351         Decimal('0.624499800')
05352         >>> ExtendedContext.sqrt(Decimal('100'))
05353         Decimal('10')
05354         >>> ExtendedContext.sqrt(Decimal('1'))
05355         Decimal('1')
05356         >>> ExtendedContext.sqrt(Decimal('1.0'))
05357         Decimal('1.0')
05358         >>> ExtendedContext.sqrt(Decimal('1.00'))
05359         Decimal('1.0')
05360         >>> ExtendedContext.sqrt(Decimal('7'))
05361         Decimal('2.64575131')
05362         >>> ExtendedContext.sqrt(Decimal('10'))
05363         Decimal('3.16227766')
05364         >>> ExtendedContext.sqrt(2)
05365         Decimal('1.41421356')
05366         >>> ExtendedContext.prec
05367         9
05368         """
05369         a = _convert_other(a, raiseit=True)
05370         return a.sqrt(context=self)

Here is the call graph for this function:

def decimal.Context.subtract (   self,
  a,
  b 
)
Return the difference between the two operands.

>>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.07'))
Decimal('0.23')
>>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.30'))
Decimal('0.00')
>>> ExtendedContext.subtract(Decimal('1.3'), Decimal('2.07'))
Decimal('-0.77')
>>> ExtendedContext.subtract(8, 5)
Decimal('3')
>>> ExtendedContext.subtract(Decimal(8), 5)
Decimal('3')
>>> ExtendedContext.subtract(8, Decimal(5))
Decimal('3')

Definition at line 5371 of file decimal.py.

05371 
05372     def subtract(self, a, b):
05373         """Return the difference between the two operands.
05374 
05375         >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.07'))
05376         Decimal('0.23')
05377         >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.30'))
05378         Decimal('0.00')
05379         >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('2.07'))
05380         Decimal('-0.77')
05381         >>> ExtendedContext.subtract(8, 5)
05382         Decimal('3')
05383         >>> ExtendedContext.subtract(Decimal(8), 5)
05384         Decimal('3')
05385         >>> ExtendedContext.subtract(8, Decimal(5))
05386         Decimal('3')
05387         """
05388         a = _convert_other(a, raiseit=True)
05389         r = a.__sub__(b, context=self)
05390         if r is NotImplemented:
05391             raise TypeError("Unable to convert %s to Decimal" % b)
05392         else:
05393             return r

Here is the call graph for this function:

def decimal.Context.to_eng_string (   self,
  a 
)
Converts a number to a string, using scientific notation.

The operation is not affected by the context.

Definition at line 5394 of file decimal.py.

05394 
05395     def to_eng_string(self, a):
05396         """Converts a number to a string, using scientific notation.
05397 
05398         The operation is not affected by the context.
05399         """
05400         a = _convert_other(a, raiseit=True)
05401         return a.to_eng_string(context=self)

Here is the call graph for this function:

def decimal.Context.to_integral_exact (   self,
  a 
)
Rounds to an integer.

When the operand has a negative exponent, the result is the same
as using the quantize() operation using the given operand as the
left-hand-operand, 1E+0 as the right-hand-operand, and the precision
of the operand as the precision setting; Inexact and Rounded flags
are allowed in this operation.  The rounding mode is taken from the
context.

>>> ExtendedContext.to_integral_exact(Decimal('2.1'))
Decimal('2')
>>> ExtendedContext.to_integral_exact(Decimal('100'))
Decimal('100')
>>> ExtendedContext.to_integral_exact(Decimal('100.0'))
Decimal('100')
>>> ExtendedContext.to_integral_exact(Decimal('101.5'))
Decimal('102')
>>> ExtendedContext.to_integral_exact(Decimal('-101.5'))
Decimal('-102')
>>> ExtendedContext.to_integral_exact(Decimal('10E+5'))
Decimal('1.0E+6')
>>> ExtendedContext.to_integral_exact(Decimal('7.89E+77'))
Decimal('7.89E+77')
>>> ExtendedContext.to_integral_exact(Decimal('-Inf'))
Decimal('-Infinity')

Definition at line 5410 of file decimal.py.

05410 
05411     def to_integral_exact(self, a):
05412         """Rounds to an integer.
05413 
05414         When the operand has a negative exponent, the result is the same
05415         as using the quantize() operation using the given operand as the
05416         left-hand-operand, 1E+0 as the right-hand-operand, and the precision
05417         of the operand as the precision setting; Inexact and Rounded flags
05418         are allowed in this operation.  The rounding mode is taken from the
05419         context.
05420 
05421         >>> ExtendedContext.to_integral_exact(Decimal('2.1'))
05422         Decimal('2')
05423         >>> ExtendedContext.to_integral_exact(Decimal('100'))
05424         Decimal('100')
05425         >>> ExtendedContext.to_integral_exact(Decimal('100.0'))
05426         Decimal('100')
05427         >>> ExtendedContext.to_integral_exact(Decimal('101.5'))
05428         Decimal('102')
05429         >>> ExtendedContext.to_integral_exact(Decimal('-101.5'))
05430         Decimal('-102')
05431         >>> ExtendedContext.to_integral_exact(Decimal('10E+5'))
05432         Decimal('1.0E+6')
05433         >>> ExtendedContext.to_integral_exact(Decimal('7.89E+77'))
05434         Decimal('7.89E+77')
05435         >>> ExtendedContext.to_integral_exact(Decimal('-Inf'))
05436         Decimal('-Infinity')
05437         """
05438         a = _convert_other(a, raiseit=True)
05439         return a.to_integral_exact(context=self)

Here is the call graph for this function:

def decimal.Context.to_integral_value (   self,
  a 
)
Rounds to an integer.

When the operand has a negative exponent, the result is the same
as using the quantize() operation using the given operand as the
left-hand-operand, 1E+0 as the right-hand-operand, and the precision
of the operand as the precision setting, except that no flags will
be set.  The rounding mode is taken from the context.

>>> ExtendedContext.to_integral_value(Decimal('2.1'))
Decimal('2')
>>> ExtendedContext.to_integral_value(Decimal('100'))
Decimal('100')
>>> ExtendedContext.to_integral_value(Decimal('100.0'))
Decimal('100')
>>> ExtendedContext.to_integral_value(Decimal('101.5'))
Decimal('102')
>>> ExtendedContext.to_integral_value(Decimal('-101.5'))
Decimal('-102')
>>> ExtendedContext.to_integral_value(Decimal('10E+5'))
Decimal('1.0E+6')
>>> ExtendedContext.to_integral_value(Decimal('7.89E+77'))
Decimal('7.89E+77')
>>> ExtendedContext.to_integral_value(Decimal('-Inf'))
Decimal('-Infinity')

Definition at line 5440 of file decimal.py.

05440 
05441     def to_integral_value(self, a):
05442         """Rounds to an integer.
05443 
05444         When the operand has a negative exponent, the result is the same
05445         as using the quantize() operation using the given operand as the
05446         left-hand-operand, 1E+0 as the right-hand-operand, and the precision
05447         of the operand as the precision setting, except that no flags will
05448         be set.  The rounding mode is taken from the context.
05449 
05450         >>> ExtendedContext.to_integral_value(Decimal('2.1'))
05451         Decimal('2')
05452         >>> ExtendedContext.to_integral_value(Decimal('100'))
05453         Decimal('100')
05454         >>> ExtendedContext.to_integral_value(Decimal('100.0'))
05455         Decimal('100')
05456         >>> ExtendedContext.to_integral_value(Decimal('101.5'))
05457         Decimal('102')
05458         >>> ExtendedContext.to_integral_value(Decimal('-101.5'))
05459         Decimal('-102')
05460         >>> ExtendedContext.to_integral_value(Decimal('10E+5'))
05461         Decimal('1.0E+6')
05462         >>> ExtendedContext.to_integral_value(Decimal('7.89E+77'))
05463         Decimal('7.89E+77')
05464         >>> ExtendedContext.to_integral_value(Decimal('-Inf'))
05465         Decimal('-Infinity')
05466         """
05467         a = _convert_other(a, raiseit=True)
05468         return a.to_integral_value(context=self)

Here is the call graph for this function:

def decimal.Context.to_sci_string (   self,
  a 
)
Converts a number to a string, using scientific notation.

The operation is not affected by the context.

Definition at line 5402 of file decimal.py.

05402 
05403     def to_sci_string(self, a):
05404         """Converts a number to a string, using scientific notation.
05405 
05406         The operation is not affected by the context.
05407         """
05408         a = _convert_other(a, raiseit=True)
05409         return a.__str__(context=self)

Here is the call graph for this function:


Member Data Documentation

decimal.Context.__copy__ = copy [static, private]

Definition at line 3882 of file decimal.py.

decimal.Context.__hash__ = None [static, private]

Definition at line 3947 of file decimal.py.

Definition at line 3833 of file decimal.py.

Definition at line 3829 of file decimal.py.

Definition at line 3830 of file decimal.py.

Definition at line 3828 of file decimal.py.

Definition at line 3827 of file decimal.py.

Definition at line 3845 of file decimal.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

Definition at line 3825 of file decimal.py.

Definition at line 3826 of file decimal.py.

Definition at line 5470 of file decimal.py.

Definition at line 3838 of file decimal.py.


Property Documentation

decimal.Context._clamp = property(_get_clamp, _set_clamp) [static, private]

Definition at line 3904 of file decimal.py.


The documentation for this class was generated from the following file: