OLD | NEW |
1 :mod:`decimal` --- Decimal fixed point and floating point arithmetic | 1 :mod:`decimal` --- Decimal fixed point and floating point arithmetic |
2 ==================================================================== | 2 ==================================================================== |
3 | 3 |
4 .. module:: decimal | 4 .. module:: decimal |
5 :synopsis: Implementation of the General Decimal Arithmetic Specification. | 5 :synopsis: Implementation of the General Decimal Arithmetic Specification. |
6 | 6 |
7 .. moduleauthor:: Eric Price <eprice at tjhsst.edu> | 7 .. moduleauthor:: Eric Price <eprice at tjhsst.edu> |
8 .. moduleauthor:: Facundo Batista <facundo at taniquetil.com.ar> | 8 .. moduleauthor:: Facundo Batista <facundo at taniquetil.com.ar> |
9 .. moduleauthor:: Raymond Hettinger <python at rcn.com> | 9 .. moduleauthor:: Raymond Hettinger <python at rcn.com> |
10 .. moduleauthor:: Aahz <aahz at pobox.com> | 10 .. moduleauthor:: Aahz <aahz at pobox.com> |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 | 647 |
648 If the two operands are unequal, return the number closest to the first | 648 If the two operands are unequal, return the number closest to the first |
649 operand in the direction of the second operand. If both operands are | 649 operand in the direction of the second operand. If both operands are |
650 numerically equal, return a copy of the first operand with the sign set to | 650 numerically equal, return a copy of the first operand with the sign set to |
651 be the same as the sign of the second operand. | 651 be the same as the sign of the second operand. |
652 | 652 |
653 .. method:: normalize([context]) | 653 .. method:: normalize([context]) |
654 | 654 |
655 Normalize the number by stripping the rightmost trailing zeros and | 655 Normalize the number by stripping the rightmost trailing zeros and |
656 converting any result equal to :const:`Decimal('0')` to | 656 converting any result equal to :const:`Decimal('0')` to |
657 :const:`Decimal('0e0')`. Used for producing canonical values for attribute
s | 657 :const:`Decimal('0e0')`. Used for producing canonical values for members |
658 of an equivalence class. For example, ``Decimal('32.100')`` and | 658 of an equivalence class. For example, ``Decimal('32.100')`` and |
659 ``Decimal('0.321000e+2')`` both normalize to the equivalent value | 659 ``Decimal('0.321000e+2')`` both normalize to the equivalent value |
660 ``Decimal('32.1')``. | 660 ``Decimal('32.1')``. |
661 | 661 |
662 .. method:: number_class([context]) | 662 .. method:: number_class([context]) |
663 | 663 |
664 Return a string describing the *class* of the operand. The returned value | 664 Return a string describing the *class* of the operand. The returned value |
665 is one of the following ten strings. | 665 is one of the following ten strings. |
666 | 666 |
667 * ``"-Infinity"``, indicating that the operand is negative infinity. | 667 * ``"-Infinity"``, indicating that the operand is negative infinity. |
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1915 >>> getcontext().prec = 3 | 1915 >>> getcontext().prec = 3 |
1916 >>> +Decimal('1.23456789') # unary plus triggers rounding | 1916 >>> +Decimal('1.23456789') # unary plus triggers rounding |
1917 Decimal('1.23') | 1917 Decimal('1.23') |
1918 | 1918 |
1919 Alternatively, inputs can be rounded upon creation using the | 1919 Alternatively, inputs can be rounded upon creation using the |
1920 :meth:`Context.create_decimal` method: | 1920 :meth:`Context.create_decimal` method: |
1921 | 1921 |
1922 >>> Context(prec=5, rounding=ROUND_DOWN).create_decimal('1.2345678') | 1922 >>> Context(prec=5, rounding=ROUND_DOWN).create_decimal('1.2345678') |
1923 Decimal('1.2345') | 1923 Decimal('1.2345') |
1924 | 1924 |
OLD | NEW |