diff options
author | Christian Heimes <christian@cheimes.de> | 2008-02-14 08:27:37 +0000 |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2008-02-14 08:27:37 +0000 |
commit | 675cc03c46b3e7fed3911ec0b967d383c045f18e (patch) | |
tree | 3632cd20da367c6fbbb8f295e22f929109b62b2c /Lib/decimal.py | |
parent | b10e2bf0ada2300b26ecccb67d10e54520c495a3 (diff) | |
download | cpython-675cc03c46b3e7fed3911ec0b967d383c045f18e.tar.gz |
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60766,60769-60786 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60752 | mark.dickinson | 2008-02-12 22:31:59 +0100 (Tue, 12 Feb 2008) | 5 lines
Implementation of Fraction.limit_denominator.
Remove Fraction.to_continued_fraction and
Fraction.from_continued_fraction
........
r60754 | mark.dickinson | 2008-02-12 22:40:53 +0100 (Tue, 12 Feb 2008) | 3 lines
Revert change in r60712: turn alternate constructors back into
classmethods instead of staticmethods.
........
r60755 | mark.dickinson | 2008-02-12 22:46:54 +0100 (Tue, 12 Feb 2008) | 4 lines
Replace R=fractions.Fraction with F=fractions.Fraction in
test_fractions.py. This should have been part of the name
change from Rational to Fraction.
........
r60758 | georg.brandl | 2008-02-13 08:20:22 +0100 (Wed, 13 Feb 2008) | 3 lines
#2063: correct order of utime and stime in os.times()
result on Windows.
........
r60762 | jeffrey.yasskin | 2008-02-13 18:58:04 +0100 (Wed, 13 Feb 2008) | 7 lines
Working on issue #1762: Brought
./python.exe -m timeit -s 'from fractions import Fraction; f = Fraction(3, 2)' 'isinstance(3, Fraction); isinstance(f, Fraction)'
from 12.3 usec/loop to 3.44 usec/loop and
./python.exe -m timeit -s 'from fractions import Fraction' 'Fraction(3, 2)'
from 48.8 usec to 23.6 usec by avoiding genexps and sets in __instancecheck__
and inlining the common case from __subclasscheck__.
........
r60765 | brett.cannon | 2008-02-13 20:15:44 +0100 (Wed, 13 Feb 2008) | 5 lines
Fix --enable-universalsdk and its comment line so that zsh's flag completion
works.
Thanks to Jeroen Ruigrok van der Werven for the fix.
........
r60771 | kurt.kaiser | 2008-02-14 01:08:55 +0100 (Thu, 14 Feb 2008) | 2 lines
Bring NEWS.txt up to date from check-in msgs.
........
r60772 | raymond.hettinger | 2008-02-14 02:08:02 +0100 (Thu, 14 Feb 2008) | 3 lines
Update notes on Decimal.
........
r60773 | raymond.hettinger | 2008-02-14 03:41:22 +0100 (Thu, 14 Feb 2008) | 1 line
Fix decimal repr which should have used single quotes like other reprs.
........
r60785 | jeffrey.yasskin | 2008-02-14 07:12:24 +0100 (Thu, 14 Feb 2008) | 11 lines
Performance optimizations on Fraction's constructor.
./python.exe -m timeit -s 'from fractions import Fraction' 'Fraction(3)`
31.7 usec/loop -> 9.2 usec/loop
./python.exe -m timeit -s 'from fractions import Fraction' 'Fraction(3, 2)'`
27.7 usec/loop -> 9.32 usec/loop
./python.exe -m timeit -s 'from fractions import Fraction; f = Fraction(3, 2)' 'Fraction(f)'
31.9 usec/loop -> 14.3 usec/loop
........
r60786 | jeffrey.yasskin | 2008-02-14 08:49:25 +0100 (Thu, 14 Feb 2008) | 5 lines
Change simple instances (in Fraction) of self.numerator and self.denominator to
self._numerator and self._denominator. This speeds abs() up from 12.2us to
10.8us and trunc() from 2.07us to 1.11us. This doesn't change _add and friends
because they're more complicated.
........
Diffstat (limited to 'Lib/decimal.py')
-rw-r--r-- | Lib/decimal.py | 484 |
1 files changed, 242 insertions, 242 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py index 2745065910..94a45684e8 100644 --- a/Lib/decimal.py +++ b/Lib/decimal.py @@ -35,26 +35,26 @@ issues associated with binary floating point. The package is especially useful for financial applications or for contexts where users have expectations that are at odds with binary floating point (for instance, in binary floating point, 1.00 % 0.1 gives 0.09999999999999995 instead -of the expected Decimal("0.00") returned by decimal floating point). +of the expected Decimal('0.00') returned by decimal floating point). Here are some examples of using the decimal module: >>> from decimal import * >>> setcontext(ExtendedContext) >>> Decimal(0) -Decimal("0") ->>> Decimal("1") -Decimal("1") ->>> Decimal("-.0123") -Decimal("-0.0123") +Decimal('0') +>>> Decimal('1') +Decimal('1') +>>> Decimal('-.0123') +Decimal('-0.0123') >>> Decimal(123456) -Decimal("123456") ->>> Decimal("123.45e12345678901234567890") -Decimal("1.2345E+12345678901234567892") ->>> Decimal("1.33") + Decimal("1.27") -Decimal("2.60") ->>> Decimal("12.34") + Decimal("3.87") - Decimal("18.41") -Decimal("-2.20") +Decimal('123456') +>>> Decimal('123.45e12345678901234567890') +Decimal('1.2345E+12345678901234567892') +>>> Decimal('1.33') + Decimal('1.27') +Decimal('2.60') +>>> Decimal('12.34') + Decimal('3.87') - Decimal('18.41') +Decimal('-2.20') >>> dig = Decimal(1) >>> print(dig / Decimal(3)) 0.333333333 @@ -91,7 +91,7 @@ decimal.DivisionByZero: x / 0 >>> print(c.flags[InvalidOperation]) 0 >>> c.divide(Decimal(0), Decimal(0)) -Decimal("NaN") +Decimal('NaN') >>> c.traps[InvalidOperation] = 1 >>> print(c.flags[InvalidOperation]) 1 @@ -517,15 +517,15 @@ class Decimal(_numbers.Real, _numbers.Inexact): """Create a decimal point instance. >>> Decimal('3.14') # string input - Decimal("3.14") + Decimal('3.14') >>> Decimal((0, (3, 1, 4), -2)) # tuple (sign, digit_tuple, exponent) - Decimal("3.14") + Decimal('3.14') >>> Decimal(314) # int - Decimal("314") + Decimal('314') >>> Decimal(Decimal(314)) # another decimal instance - Decimal("314") + Decimal('314') >>> Decimal(' 3.14 \\n') # leading and trailing whitespace okay - Decimal("3.14") + Decimal('3.14') """ # Note that the coefficient, self._int, is actually stored as @@ -885,7 +885,7 @@ class Decimal(_numbers.Real, _numbers.Inexact): # # The hash of a nonspecial noninteger Decimal must depend only # on the value of that Decimal, and not on its representation. - # For example: hash(Decimal("100E-1")) == hash(Decimal("10")). + # For example: hash(Decimal('100E-1')) == hash(Decimal('10')). if self._is_special: if self._isnan(): raise TypeError('Cannot hash a NaN value.') @@ -919,7 +919,7 @@ class Decimal(_numbers.Real, _numbers.Inexact): def __repr__(self): """Represents the number as an instance of Decimal.""" # Invariant: eval(repr(d)) == d - return 'Decimal("%s")' % str(self) + return "Decimal('%s')" % str(self) def __str__(self, eng=False, context=None): """Return string representation of the number in scientific notation. @@ -3637,13 +3637,13 @@ class Context(object): the plus operation on the operand. >>> ExtendedContext.abs(Decimal('2.1')) - Decimal("2.1") + Decimal('2.1') >>> ExtendedContext.abs(Decimal('-100')) - Decimal("100") + Decimal('100') >>> ExtendedContext.abs(Decimal('101.5')) - Decimal("101.5") + Decimal('101.5') >>> ExtendedContext.abs(Decimal('-101.5')) - Decimal("101.5") + Decimal('101.5') """ return a.__abs__(context=self) @@ -3651,9 +3651,9 @@ class Context(object): """Return the sum of the two operands. >>> ExtendedContext.add(Decimal('12'), Decimal('7.00')) - Decimal("19.00") + Decimal('19.00') >>> ExtendedContext.add(Decimal('1E+2'), Decimal('1.01E+4')) - Decimal("1.02E+4") + Decimal('1.02E+4') """ return a.__add__(b, context=self) @@ -3667,7 +3667,7 @@ class Context(object): received object already is in its canonical form. >>> ExtendedContext.canonical(Decimal('2.50')) - Decimal("2.50") + Decimal('2.50') """ return a.canonical(context=self) @@ -3686,17 +3686,17 @@ class Context(object): zero or negative zero, or '1' if the result is greater than zero. >>> ExtendedContext.compare(Decimal('2.1'), Decimal('3')) - Decimal("-1") + Decimal('-1') >>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.1')) - Decimal("0") + Decimal('0') >>> ExtendedContext.compare(Decimal('2.1'), Decimal('2.10')) - Decimal("0") + Decimal('0') >>> ExtendedContext.compare(Decimal('3'), Decimal('2.1')) - Decimal("1") + Decimal('1') >>> ExtendedContext.compare(Decimal('2.1'), Decimal('-3')) - Decimal("1") + Decimal('1') >>> ExtendedContext.compare(Decimal('-3'), Decimal('2.1')) - Decimal("-1") + Decimal('-1') """ return a.compare(b, context=self) @@ -3708,21 +3708,21 @@ class Context(object): >>> c = ExtendedContext >>> c.compare_signal(Decimal('2.1'), Decimal('3')) - Decimal("-1") + Decimal('-1') >>> c.compare_signal(Decimal('2.1'), Decimal('2.1')) - Decimal("0") + Decimal('0') >>> c.flags[InvalidOperation] = 0 >>> print(c.flags[InvalidOperation]) 0 >>> c.compare_signal(Decimal('NaN'), Decimal('2.1')) - Decimal("NaN") + 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") + Decimal('NaN') >>> print(c.flags[InvalidOperation]) 1 """ @@ -3736,17 +3736,17 @@ class Context(object): representations. >>> ExtendedContext.compare_total(Decimal('12.73'), Decimal('127.9')) - Decimal("-1") + Decimal('-1') >>> ExtendedContext.compare_total(Decimal('-127'), Decimal('12')) - Decimal("-1") + Decimal('-1') >>> ExtendedContext.compare_total(Decimal('12.30'), Decimal('12.3')) - Decimal("-1") + Decimal('-1') >>> ExtendedContext.compare_total(Decimal('12.30'), Decimal('12.30')) - Decimal("0") + Decimal('0') >>> ExtendedContext.compare_total(Decimal('12.3'), Decimal('12.300')) - Decimal("1") + Decimal('1') >>> ExtendedContext.compare_total(Decimal('12.3'), Decimal('NaN')) - Decimal("-1") + Decimal('-1') """ return a.compare_total(b) @@ -3761,9 +3761,9 @@ class Context(object): """Returns a copy of the operand with the sign set to 0. >>> ExtendedContext.copy_abs(Decimal('2.1')) - Decimal("2.1") + Decimal('2.1') >>> ExtendedContext.copy_abs(Decimal('-100')) - Decimal("100") + Decimal('100') """ return a.copy_abs() @@ -3771,9 +3771,9 @@ class Context(object): """Returns a copy of the decimal objet. >>> ExtendedContext.copy_decimal(Decimal('2.1')) - Decimal("2.1") + Decimal('2.1') >>> ExtendedContext.copy_decimal(Decimal('-1.00')) - Decimal("-1.00") + Decimal('-1.00') """ return Decimal(a) @@ -3781,9 +3781,9 @@ class Context(object): """Returns a copy of the operand with the sign inverted. >>> ExtendedContext.copy_negate(Decimal('101.5')) - Decimal("-101.5") + Decimal('-101.5') >>> ExtendedContext.copy_negate(Decimal('-101.5')) - Decimal("101.5") + Decimal('101.5') """ return a.copy_negate() @@ -3794,13 +3794,13 @@ class Context(object): equal to the sign of the second operand. >>> ExtendedContext.copy_sign(Decimal( '1.50'), Decimal('7.33')) - Decimal("1.50") + Decimal('1.50') >>> ExtendedContext.copy_sign(Decimal('-1.50'), Decimal('7.33')) - Decimal("1.50") + Decimal('1.50') >>> ExtendedContext.copy_sign(Decimal( '1.50'), Decimal('-7.33')) - Decimal("-1.50") + Decimal('-1.50') >>> ExtendedContext.copy_sign(Decimal('-1.50'), Decimal('-7.33')) - Decimal("-1.50") + Decimal('-1.50') """ return a.copy_sign(b) @@ -3808,25 +3808,25 @@ class Context(object): """Decimal division in a specified context. >>> ExtendedContext.divide(Decimal('1'), Decimal('3')) - Decimal("0.333333333") + Decimal('0.333333333') >>> ExtendedContext.divide(Decimal('2'), Decimal('3')) - Decimal("0.666666667") + Decimal('0.666666667') >>> ExtendedContext.divide(Decimal('5'), Decimal('2')) - Decimal("2.5") + Decimal('2.5') >>> ExtendedContext.divide(Decimal('1'), Decimal('10')) - Decimal("0.1") + Decimal('0.1') >>> ExtendedContext.divide(Decimal('12'), Decimal('12')) - Decimal("1") + Decimal('1') >>> ExtendedContext.divide(Decimal('8.00'), Decimal('2')) - Decimal("4.00") + Decimal('4.00') >>> ExtendedContext.divide(Decimal('2.400'), Decimal('2.0')) - Decimal("1.20") + Decimal('1.20') >>> ExtendedContext.divide(Decimal('1000'), Decimal('100')) - Decimal("10") + Decimal('10') >>> ExtendedContext.divide(Decimal('1000'), Decimal('1')) - Decimal("1000") + Decimal('1000') >>> ExtendedContext.divide(Decimal('2.40E+6'), Decimal('2')) - Decimal("1.20E+6") + Decimal('1.20E+6') """ return a.__truediv__(b, context=self) @@ -3834,11 +3834,11 @@ class Context(object): """Divides two numbers and returns the integer part of the result. >>> ExtendedContext.divide_int(Decimal('2'), Decimal('3')) - Decimal("0") + Decimal('0') >>> ExtendedContext.divide_int(Decimal('10'), Decimal('3')) - Decimal("3") + Decimal('3') >>> ExtendedContext.divide_int(Decimal('1'), Decimal('0.3')) - Decimal("3") + Decimal('3') """ return a.__floordiv__(b, context=self) @@ -3852,17 +3852,17 @@ class Context(object): >>> c.Emin = -999 >>> c.Emax = 999 >>> c.exp(Decimal('-Infinity')) - Decimal("0") + Decimal('0') >>> c.exp(Decimal('-1')) - Decimal("0.367879441") + Decimal('0.367879441') >>> c.exp(Decimal('0')) - Decimal("1") + Decimal('1') >>> c.exp(Decimal('1')) - Decimal("2.71828183") + Decimal('2.71828183') >>> c.exp(Decimal('0.693147181')) - Decimal("2.00000000") + Decimal('2.00000000') >>> c.exp(Decimal('+Infinity')) - Decimal("Infinity") + Decimal('Infinity') """ return a.exp(context=self) @@ -3874,11 +3874,11 @@ class Context(object): multiplication, using add, all with only one final rounding. >>> ExtendedContext.fma(Decimal('3'), Decimal('5'), Decimal('7')) - Decimal("22") + Decimal('22') >>> ExtendedContext.fma(Decimal('3'), Decimal('-5'), Decimal('7')) - Decimal("-8") + Decimal('-8') >>> ExtendedContext.fma(Decimal('888565290'), Decimal('1557.96930'), Decimal('-86087.7578')) - Decimal("1.38435736E+12") + Decimal('1.38435736E+12') """ return a.fma(b, c, context=self) @@ -4032,15 +4032,15 @@ class Context(object): >>> c.Emin = -999 >>> c.Emax = 999 >>> c.ln(Decimal('0')) - Decimal("-Infinity") + Decimal('-Infinity') >>> c.ln(Decimal('1.000')) - Decimal("0") + Decimal('0') >>> c.ln(Decimal('2.71828183')) - Decimal("1.00000000") + Decimal('1.00000000') >>> c.ln(Decimal('10')) - Decimal("2.30258509") + Decimal('2.30258509') >>> c.ln(Decimal('+Infinity')) - Decimal("Infinity") + Decimal('Infinity') """ return a.ln(context=self) @@ -4051,19 +4051,19 @@ class Context(object): >>> c.Emin = -999 >>> c.Emax = 999 >>> c.log10(Decimal('0')) - Decimal("-Infinity") + Decimal('-Infinity') >>> c.log10(Decimal('0.001')) - Decimal("-3") + Decimal('-3') >>> c.log10(Decimal('1.000')) - Decimal("0") + Decimal('0') >>> c.log10(Decimal('2')) - Decimal("0.301029996") + Decimal('0.301029996') >>> c.log10(Decimal('10')) - Decimal("1") + Decimal('1') >>> c.log10(Decimal('70')) - Decimal("1.84509804") + Decimal('1.84509804') >>> c.log10(Decimal('+Infinity')) - Decimal("Infinity") + Decimal('Infinity') """ return a.log10(context=self) @@ -4076,13 +4076,13 @@ class Context(object): value of that digit and without limiting the resulting exponent). >>> ExtendedContext.logb(Decimal('250')) - Decimal("2") + Decimal('2') >>> ExtendedContext.logb(Decimal('2.50')) - Decimal("0") + Decimal('0') >>> ExtendedContext.logb(Decimal('0.03')) - Decimal("-2") + Decimal('-2') >>> ExtendedContext.logb(Decimal('0')) - Decimal("-Infinity") + Decimal('-Infinity') """ return a.logb(context=self) @@ -4092,17 +4092,17 @@ class Context(object): The operands must be both logical numbers. >>> ExtendedContext.logical_and(Decimal('0'), Decimal('0')) - Decimal("0") + Decimal('0') >>> ExtendedContext.logical_and(Decimal('0'), Decimal('1')) - Decimal("0") + Decimal('0') >>> ExtendedContext.logical_and(Decimal('1'), Decimal('0')) - Decimal("0") + Decimal('0') >>> ExtendedContext.logical_and(Decimal('1'), Decimal('1')) - Decimal("1") + Decimal('1') >>> ExtendedContext.logical_and(Decimal('1100'), Decimal('1010')) - Decimal("1000") + Decimal('1000') >>> ExtendedContext.logical_and(Decimal('1111'), Decimal('10')) - Decimal("10") + Decimal('10') """ return a.logical_and(b, context=self) @@ -4112,13 +4112,13 @@ class Context(object): The operand must be a logical number. >>> ExtendedContext.logical_invert(Decimal('0')) - Decimal("111111111") + Decimal('111111111') >>> ExtendedContext.logical_invert(Decimal('1')) - Decimal("111111110") + Decimal('111111110') >>> ExtendedContext.logical_invert(Decimal('111111111')) - Decimal("0") + Decimal('0') >>> ExtendedContext.logical_invert(Decimal('101010101')) - Decimal("10101010") + Decimal('10101010') """ return a.logical_invert(context=self) @@ -4128,17 +4128,17 @@ class Context(object): The operands must be both logical numbers. >>> ExtendedContext.logical_or(Decimal('0'), Decimal('0')) - Decimal("0") + Decimal('0') >>> ExtendedContext.logical_or(Decimal('0'), Decimal('1')) - Decimal("1") + Decimal('1') >>> ExtendedContext.logical_or(Decimal('1'), Decimal('0')) - Decimal("1") + Decimal('1') >>> ExtendedContext.logical_or(Decimal('1'), Decimal('1')) - Decimal("1") + Decimal('1') >>> ExtendedContext.logical_or(Decimal('1100'), Decimal('1010')) - Decimal("1110") + Decimal('1110') >>> ExtendedContext.logical_or(Decimal('1110'), Decimal('10')) - Decimal("1110") + Decimal('1110') """ return a.logical_or(b, context=self) @@ -4148,17 +4148,17 @@ class Context(object): The operands must be both logical numbers. >>> ExtendedContext.logical_xor(Decimal('0'), Decimal('0')) - Decimal("0") + Decimal('0') >>> ExtendedContext.logical_xor(Decimal('0'), Decimal('1')) - Decimal("1") + Decimal('1') >>> ExtendedContext.logical_xor(Decimal('1'), Decimal('0')) - Decimal("1") + Decimal('1') >>> ExtendedContext.logical_xor(Decimal('1'), Decimal('1')) - Decimal("0") + Decimal('0') >>> ExtendedContext.logical_xor(Decimal('1100'), Decimal('1010')) - Decimal("110") + Decimal('110') >>> ExtendedContext.logical_xor(Decimal('1111'), Decimal('10')) - Decimal("1101") + Decimal('1101') """ return a.logical_xor(b, context=self) @@ -4172,13 +4172,13 @@ class Context(object): infinity) of the two operands is chosen as the result. >>> ExtendedContext.max(Decimal('3'), Decimal('2')) - Decimal("3") + Decimal('3') >>> ExtendedContext.max(Decimal('-10'), Decimal('3')) - Decimal("3") + Decimal('3') >>> ExtendedContext.max(Decimal('1.0'), Decimal('1')) - Decimal("1") + Decimal('1') >>> ExtendedContext.max(Decimal('7'), Decimal('NaN')) - Decimal("7") + Decimal('7') """ return a.max(b, context=self) @@ -4196,13 +4196,13 @@ class Context(object): infinity) of the two operands is chosen as the result. >>> ExtendedContext.min(Decimal('3'), Decimal('2')) - Decimal("2") + Decimal('2') >>> ExtendedContext.min(Decimal('-10'), Decimal('3')) - Decimal("-10") + Decimal('-10') >>> ExtendedContext.min(Decimal('1.0'), Decimal('1')) - Decimal("1.0") + Decimal('1.0') >>> ExtendedContext.min(Decimal('7'), Decimal('NaN')) - Decimal("7") + Decimal('7') """ return a.min(b, context=self) @@ -4218,9 +4218,9 @@ class Context(object): has the same exponent as the operand. >>> ExtendedContext.minus(Decimal('1.3')) - Decimal("-1.3") + Decimal('-1.3') >>> ExtendedContext.minus(Decimal('-1.3')) - Decimal("1.3") + Decimal('1.3') """ return a.__neg__(context=self) @@ -4233,15 +4233,15 @@ class Context(object): of the two operands. >>> ExtendedContext.multiply(Decimal('1.20'), Decimal('3')) - Decimal("3.60") + Decimal('3.60') >>> ExtendedContext.multiply(Decimal('7'), Decimal('3')) - Decimal("21") + Decimal('21') >>> ExtendedContext.multiply(Decimal('0.9'), Decimal('0.8')) - Decimal("0.72") + Decimal('0.72') >>> ExtendedContext.multiply(Decimal('0.9'), Decimal('-0')) - Decimal("-0.0") + Decimal('-0.0') >>> ExtendedContext.multiply(Decimal('654321'), Decimal('654321')) - Decimal("4.28135971E+11") + Decimal('4.28135971E+11') """ return a.__mul__(b, context=self) @@ -4252,13 +4252,13 @@ class Context(object): >>> c.Emin = -999 >>> c.Emax = 999 >>> ExtendedContext.next_minus(Decimal('1')) - Decimal("0.999999999") + Decimal('0.999999999') >>> c.next_minus(Decimal('1E-1007')) - Decimal("0E-1007") + Decimal('0E-1007') >>> ExtendedContext.next_minus(Decimal('-1.00000003')) - Decimal("-1.00000004") + Decimal('-1.00000004') >>> c.next_minus(Decimal('Infinity')) - Decimal("9.99999999E+999") + Decimal('9.99999999E+999') """ return a.next_minus(context=self) @@ -4269,13 +4269,13 @@ class Context(object): >>> c.Emin = -999 >>> c.Emax = 999 >>> ExtendedContext.next_plus(Decimal('1')) - Decimal("1.00000001") + Decimal('1.00000001') >>> c.next_plus(Decimal('-1E-1007')) - Decimal("-0E-1007") + Decimal('-0E-1007') >>> ExtendedContext.next_plus(Decimal('-1.00000003')) - Decimal("-1.00000002") + Decimal('-1.00000002') >>> c.next_plus(Decimal('-Infinity')) - Decimal("-9.99999999E+999") + Decimal('-9.99999999E+999') """ return a.next_plus(context=self) @@ -4291,19 +4291,19 @@ class Context(object): >>> c.Emin = -999 >>> c.Emax = 999 >>> c.next_toward(Decimal('1'), Decimal('2')) - Decimal("1.00000001") + Decimal('1.00000001') >>> c.next_toward(Decimal('-1E-1007'), Decimal('1')) - Decimal("-0E-1007") + Decimal('-0E-1007') >>> c.next_toward(Decimal('-1.00000003'), Decimal('0')) - Decimal("-1.00000002") + Decimal('-1.00000002') >>> c.next_toward(Decimal('1'), Decimal('0')) - Decimal("0.999999999") + Decimal('0.999999999') >>> c.next_toward(Decimal('1E-1007'), Decimal('-100')) - Decimal("0E-1007") + Decimal('0E-1007') >>> c.next_toward(Decimal('-1.00000003'), Decimal('-10')) - Decimal("-1.00000004") + Decimal('-1.00000004') >>> c.next_toward(Decimal('0.00'), Decimal('-0.0000')) - Decimal("-0.00") + Decimal('-0.00') """ return a.next_toward(b, context=self) @@ -4314,17 +4314,17 @@ class Context(object): result. >>> ExtendedContext.normalize(Decimal('2.1')) - Decimal("2.1") + Decimal('2.1') >>> ExtendedContext.normalize(Decimal('-2.0')) - Decimal("-2") + Decimal('-2') >>> ExtendedContext.normalize(Decimal('1.200')) - Decimal("1.2") + Decimal('1.2') >>> ExtendedContext.normalize(Decimal('-120')) - Decimal("-1.2E+2") + Decimal('-1.2E+2') >>> ExtendedContext.normalize(Decimal('120.00')) - Decimal("1.2E+2") + Decimal('1.2E+2') >>> ExtendedContext.normalize(Decimal('0.00')) - Decimal("0") + Decimal('0') """ return a.normalize(context=self) @@ -4383,9 +4383,9 @@ class Context(object): has the same exponent as the operand. >>> ExtendedContext.plus(Decimal('1.3')) - Decimal("1.3") + Decimal('1.3') >>> ExtendedContext.plus(Decimal('-1.3')) - Decimal("-1.3") + Decimal('-1.3') """ return a.__pos__(context=self) @@ -4415,46 +4415,46 @@ class Context(object): >>> c.Emin = -999 >>> c.Emax = 999 >>> c.power(Decimal('2'), Decimal('3')) - Decimal("8") + Decimal('8') >>> c.power(Decimal('-2'), Decimal('3')) - Decimal("-8") + Decimal('-8') >>> c.power(Decimal('2'), Decimal('-3')) - Decimal("0.125") + Decimal('0.125') >>> c.power(Decimal('1.7'), Decimal('8')) - Decimal("69.7575744") + Decimal('69.7575744') >>> c.power(Decimal('10'), Decimal('0.301029996')) - Decimal("2.00000000") + Decimal('2.00000000') >>> c.power(Decimal('Infinity'), Decimal('-1')) - Decimal("0") + Decimal('0') >>> c.power(Decimal('Infinity'), Decimal('0')) - Decimal("1") + Decimal('1') >>> c.power(Decimal('Infinity'), Decimal('1')) - Decimal("Infinity") + Decimal('Infinity') >>> c.power(Decimal('-Infinity'), Decimal('-1')) - Decimal("-0") + Decimal('-0') >>> c.power(Decimal('-Infinity'), Decimal('0')) - Decimal("1") + Decimal('1') >>> c.power(Decimal('-Infinity'), Decimal('1')) - Decimal("-Infinity") + Decimal('-Infinity') >>> c.power(Decimal('-Infinity'), Decimal('2')) - Decimal("Infinity") + Decimal('Infinity') >>> c.power(Decimal('0'), Decimal('0')) - Decimal("NaN") + Decimal('NaN') >>> c.power(Decimal('3'), Decimal('7'), Decimal('16')) - Decimal("11") + Decimal('11') >>> c.power(Decimal('-3'), Decimal('7'), Decimal('16')) - Decimal("-11") + Decimal('-11') >>> c.power(Decimal('-3'), Decimal('8'), Decimal('16')) - Decimal("1") + Decimal('1') >>> c.power(Decimal('3'), Decimal('7'), Decimal('-16')) - Decimal("11") + Decimal('11') >>> c.power(Decimal('23E12345'), Decimal('67E189'), Decimal('123456789')) - Decimal("11729830") + Decimal('11729830') >>> c.power(Decimal('-0'), Decimal('17'), Decimal('1729')) - Decimal("-0") + Decimal('-0') >>> c.power(Decimal('-23'), Decimal('0'), Decimal('65537')) - Decimal("1") + Decimal('1') """ return a.__pow__(b, modulo, context=self) @@ -4477,35 +4477,35 @@ class Context(object): if the result is subnormal and inexact. >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.001')) - Decimal("2.170") + Decimal('2.170') >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.01')) - Decimal("2.17") + Decimal('2.17') >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.1')) - Decimal("2.2") + Decimal('2.2') >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+0')) - Decimal("2") + Decimal('2') >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+1')) - Decimal("0E+1") + Decimal('0E+1') >>> ExtendedContext.quantize(Decimal('-Inf'), Decimal('Infinity')) - Decimal("-Infinity") + Decimal('-Infinity') >>> ExtendedContext.quantize(Decimal('2'), Decimal('Infinity')) - Decimal("NaN") + Decimal('NaN') >>> ExtendedContext.quantize(Decimal('-0.1'), Decimal('1')) - Decimal("-0") + Decimal('-0') >>> ExtendedContext.quantize(Decimal('-0'), Decimal('1e+5')) - Decimal("-0E+5") + Decimal('-0E+5') >>> ExtendedContext.quantize(Decimal('+35236450.6'), Decimal('1e-2')) - Decimal("NaN") + Decimal('NaN') >>> ExtendedContext.quantize(Decimal('-35236450.6'), Decimal('1e-2')) - Decimal("NaN") + Decimal('NaN') >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-1')) - Decimal("217.0") + Decimal('217.0') >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-0')) - Decimal("217") + Decimal('217') >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+1')) - Decimal("2.2E+2") + Decimal('2.2E+2') >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+2')) - Decimal("2E+2") + Decimal('2E+2') """ return a.quantize(b, context=self) @@ -4513,7 +4513,7 @@ class Context(object): """Just returns 10, as this is Decimal, :) >>> ExtendedContext.radix() - Decimal("10") + Decimal('10') """ return Decimal(10) @@ -4530,17 +4530,17 @@ class Context(object): remainder cannot be calculated). >>> ExtendedContext.remainder(Decimal('2.1'), Decimal('3')) - Decimal("2.1") + Decimal('2.1') >>> ExtendedContext.remainder(Decimal('10'), Decimal('3')) - Decimal("1") + Decimal('1') >>> ExtendedContext.remainder(Decimal('-10'), Decimal('3')) - Decimal("-1") + Decimal('-1') >>> ExtendedContext.remainder(Decimal('10.2'), Decimal('1')) - Decimal("0.2") + Decimal('0.2') >>> ExtendedContext.remainder(Decimal('10'), Decimal('0.3')) - Decimal("0.1") + Decimal('0.1') >>> ExtendedContext.remainder(Decimal('3.6'), Decimal('1.3')) - Decimal("1.0") + Decimal('1.0') """ return a.__mod__(b, context=self) @@ -4555,19 +4555,19 @@ class Context(object): remainder cannot be calculated). >>> ExtendedContext.remainder_near(Decimal('2.1'), Decimal('3')) - Decimal("-0.9") + Decimal('-0.9') >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('6')) - Decimal("-2") + Decimal('-2') >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('3')) - Decimal("1") + Decimal('1') >>> ExtendedContext.remainder_near(Decimal('-10'), Decimal('3')) - Decimal("-1") + Decimal('-1') >>> ExtendedContext.remainder_near(Decimal('10.2'), Decimal('1')) - Decimal("0.2") + Decimal('0.2') >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('0.3')) - Decimal("0.1") + Decimal('0.1') >>> ExtendedContext.remainder_near(Decimal('3.6'), Decimal('1.3')) - Decimal("-0.3") + Decimal('-0.3') """ return a.remainder_near(b, context=self) @@ -4581,15 +4581,15 @@ class Context(object): positive or to the right otherwise. >>> ExtendedContext.rotate(Decimal('34'), Decimal('8')) - Decimal("400000003") + Decimal('400000003') >>> ExtendedContext.rotate(Decimal('12'), Decimal('9')) - Decimal("12") + Decimal('12') >>> ExtendedContext.rotate(Decimal('123456789'), Decimal('-2')) - Decimal("891234567") + Decimal('891234567') >>> ExtendedContext.rotate(Decimal('123456789'), Decimal('0')) - Decimal("123456789") + Decimal('123456789') >>> ExtendedContext.rotate(Decimal('123456789'), Decimal('+2')) - Decimal("345678912") + Decimal('345678912') """ return a.rotate(b, context=self) @@ -4614,11 +4614,11 @@ class Context(object): """Returns the first operand after adding the second value its exp. >>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('-2')) - Decimal("0.0750") + Decimal('0.0750') >>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('0')) - Decimal("7.50") + Decimal('7.50') >>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('3')) - Decimal("7.50E+3") + Decimal('7.50E+3') """ return a.scaleb (b, context=self) @@ -4633,15 +4633,15 @@ class Context(object): coefficient are zeros. >>> ExtendedContext.shift(Decimal('34'), Decimal('8')) - Decimal("400000000") + Decimal('400000000') >>> ExtendedContext.shift(Decimal('12'), Decimal('9')) - Decimal("0") + Decimal('0') >>> ExtendedContext.shift(Decimal('123456789'), Decimal('-2')) - Decimal("1234567") + Decimal('1234567') >>> ExtendedContext.shift(Decimal('123456789'), Decimal('0')) - Decimal("123456789") + Decimal('123456789') >>> ExtendedContext.shift(Decimal('123456789'), Decimal('+2')) - Decimal("345678900") + Decimal('345678900') """ return a.shift(b, context=self) @@ -4652,23 +4652,23 @@ class Context(object): algorithm. >>> ExtendedContext.sqrt(Decimal('0')) - Decimal("0") + Decimal('0') >>> ExtendedContext.sqrt(Decimal('-0')) - Decimal("-0") + Decimal('-0') >>> ExtendedContext.sqrt(Decimal('0.39')) - Decimal("0.624499800") + Decimal('0.624499800') >>> ExtendedContext.sqrt(Decimal('100')) - Decimal("10") + Decimal('10') >>> ExtendedContext.sqrt(Decimal('1')) - Decimal("1") + Decimal('1') >>> ExtendedContext.sqrt(Decimal('1.0')) - Decimal("1.0") + Decimal('1.0') >>> ExtendedContext.sqrt(Decimal('1.00')) - Decimal("1.0") + Decimal('1.0') >>> ExtendedContext.sqrt(Decimal('7')) - Decimal("2.64575131") + Decimal('2.64575131') >>> ExtendedContext.sqrt(Decimal('10')) - Decimal("3.16227766") + Decimal('3.16227766') >>> ExtendedContext.prec 9 """ @@ -4678,11 +4678,11 @@ class Context(object): """Return the difference between the two operands. >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.07')) - Decimal("0.23") + Decimal('0.23') >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('1.30')) - Decimal("0.00") + Decimal('0.00') >>> ExtendedContext.subtract(Decimal('1.3'), Decimal('2.07')) - Decimal("-0.77") + Decimal('-0.77') """ return a.__sub__(b, context=self) @@ -4711,21 +4711,21 @@ class Context(object): context. >>> ExtendedContext.to_integral_exact(Decimal('2.1')) - Decimal("2") + Decimal('2') >>> ExtendedContext.to_integral_exact(Decimal('100')) - Decimal("100") + Decimal('100') >>> ExtendedContext.to_integral_exact(Decimal('100.0')) - Decimal("100") + Decimal('100') >>> ExtendedContext.to_integral_exact(Decimal('101.5')) - Decimal("102") + Decimal('102') >>> ExtendedContext.to_integral_exact(Decimal('-101.5')) - Decimal("-102") + Decimal('-102') >>> ExtendedContext.to_integral_exact(Decimal('10E+5')) - Decimal("1.0E+6") + Decimal('1.0E+6') >>> ExtendedContext.to_integral_exact(Decimal('7.89E+77')) - Decimal("7.89E+77") + Decimal('7.89E+77') >>> ExtendedContext.to_integral_exact(Decimal('-Inf')) - Decimal("-Infinity") + Decimal('-Infinity') """ return a.to_integral_exact(context=self) @@ -4739,21 +4739,21 @@ class Context(object): be set. The rounding mode is taken from the context. >>> ExtendedContext.to_integral_value(Decimal('2.1')) - Decimal("2") + Decimal('2') >>> ExtendedContext.to_integral_value(Decimal('100')) - Decimal("100") + Decimal('100') >>> ExtendedContext.to_integral_value(Decimal('100.0')) - Decimal("100") + Decimal('100') >>> ExtendedContext.to_integral_value(Decimal('101.5')) - Decimal("102") + Decimal('102') >>> ExtendedContext.to_integral_value(Decimal('-101.5')) - Decimal("-102") + Decimal('-102') >>> ExtendedContext.to_integral_value(Decimal('10E+5')) - Decimal("1.0E+6") + Decimal('1.0E+6') >>> ExtendedContext.to_integral_value(Decimal('7.89E+77')) - Decimal("7.89E+77") + Decimal('7.89E+77') >>> ExtendedContext.to_integral_value(Decimal('-Inf')) - Decimal("-Infinity") + Decimal('-Infinity') """ return a.to_integral_value(context=self) |