Lines Matching full:decimal
11 These are the test cases for the Decimal module.
14 the Decimal arithmetic using the tests provided by Mike Cowlishaw. The latter
19 http://speleotrove.com/decimal/dectest.zip
32 from decimal import *
91 # Decimal behaves differently from decNumber for these testcases so these
149 # Name adapter to be able to change the Decimal and Context
190 # The following functions return True/False rather than a Decimal instance
207 """Class which tests the Decimal class against the test cases.
337 v = Decimal(v, self.context)
410 # The following classes test the behaviour of Decimal according to PEP 327
413 '''Unit tests for Explicit Construction cases of Decimal.'''
416 self.assertEqual(Decimal(), Decimal("0"))
419 self.assertRaises(TypeError, Decimal, None)
424 d = Decimal(45)
428 d = Decimal(500000123)
432 d = Decimal(-45)
436 d = Decimal(0)
442 self.assertEqual(str(Decimal('')), 'NaN')
445 self.assertEqual(str(Decimal('45')), '45')
448 self.assertEqual(str(Decimal('45.34')), '45.34')
451 self.assertEqual(str(Decimal('45e2')), '4.5E+3')
454 self.assertEqual(str(Decimal('ugly')), 'NaN')
457 self.assertEqual(str(Decimal('1.3E4 \n')), '1.3E+4')
458 self.assertEqual(str(Decimal(' -7.89')), '-7.89')
461 self.assertEqual(str(Decimal(u'0E-017')), '0E-17')
462 self.assertEqual(str(Decimal(u'45')), '45')
463 self.assertEqual(str(Decimal(u'-Inf')), '-Infinity')
464 self.assertEqual(str(Decimal(u'NaN123')), 'NaN123')
469 d = Decimal( (0, (0,), 0) )
473 d = Decimal( (1, (4, 5), 0) )
477 d = Decimal( (0, (4, 5, 3, 4), -2) )
481 d = Decimal( (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) )
485 self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1)) )
488 self.assertRaises(ValueError, Decimal, (8, (4, 3, 4, 9, 1), 2) )
489 self.assertRaises(ValueError, Decimal, (0., (4, 3, 4, 9, 1), 2) )
490 self.assertRaises(ValueError, Decimal, (Decimal(1), (4, 3, 4, 9, 1), 2))
493 self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1), 'wrong!') )
494 self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1), 0.) )
495 self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1), '1') )
498 self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, None, 1), 2) )
499 self.assertRaises(ValueError, Decimal, (1, (4, -3, 4, 9, 1), 2) )
500 self.assertRaises(ValueError, Decimal, (1, (4, 10, 4, 9, 1), 2) )
501 self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 'a', 1), 2) )
504 self.assertIs(bool(Decimal(0)), False)
505 self.assertIs(bool(Decimal(1)), True)
506 self.assertEqual(Decimal(False), Decimal(0))
507 self.assertEqual(Decimal(True), Decimal(1))
512 d = Decimal(45)
513 e = Decimal(d)
518 d = Decimal(500000123)
519 e = Decimal(d)
524 d = Decimal(-45)
525 e = Decimal(d)
530 d = Decimal(0)
531 e = Decimal(d)
537 r = Decimal(0.1)
538 self.assertEqual(type(r), Decimal)
541 self.assertTrue(Decimal(float('nan')).is_qnan())
542 self.assertTrue(Decimal(float('inf')).is_infinite())
543 self.assertTrue(Decimal(float('-inf')).is_infinite())
544 self.assertEqual(str(Decimal(float('nan'))),
545 str(Decimal('NaN')))
546 self.assertEqual(str(Decimal(float('inf'))),
547 str(Decimal('Infinity')))
548 self.assertEqual(str(Decimal(float('-inf'))),
549 str(Decimal('-Infinity')))
550 self.assertEqual(str(Decimal(float('-0.0'))),
551 str(Decimal('-0')))
554 self.assertEqual(x, float(Decimal(x))) # roundtrip
562 d = Decimal()
572 self.assertIsInstance(d, Decimal)
577 d = Decimal('456789')
587 d = Decimal( (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) )
592 # from Decimal
593 prevdec = Decimal(500000123)
594 d = Decimal(prevdec)
607 self.assertEqual(str(Decimal(input)), expected)
611 '''Unit tests for Implicit Construction cases of Decimal.'''
614 self.assertRaises(TypeError, eval, 'Decimal(5) + None', globals())
618 self.assertEqual(str(Decimal(5) + 45), '50')
620 self.assertEqual(Decimal(5) + 123456789000, Decimal(123456789000))
623 self.assertRaises(TypeError, eval, 'Decimal(5) + "3"', globals())
626 self.assertRaises(TypeError, eval, 'Decimal(5) + 2.2', globals())
629 self.assertEqual(Decimal(5) + Decimal(45), Decimal(50))
651 self.assertEqual(divmod(E(), Decimal(10)), 'divmod 10')
652 self.assertEqual(divmod(Decimal(10), E()), '10 rdivmod')
653 self.assertEqual(eval('Decimal(10) < E()'), 'gt 10')
654 self.assertEqual(eval('Decimal(10) > E()'), 'lt 10')
655 self.assertEqual(eval('Decimal(10) <= E()'), 'ge 10')
656 self.assertEqual(eval('Decimal(10) >= E()'), 'le 10')
657 self.assertEqual(eval('Decimal(10) == E()'), 'eq 10')
658 self.assertEqual(eval('Decimal(10) != E()'), 'ne 10')
680 self.assertEqual(eval('E()' + sym + 'Decimal(10)'),
682 self.assertEqual(eval('Decimal(10)' + sym + 'E()'),
689 # triples giving a format, a Decimal, and the expected result
725 ('.0f', '0', '0'), # no decimal point
835 self.assertEqual(format(Decimal(d), fmt), result)
870 return Decimal.__format__(Decimal(x), fmt, _localeconv=locale)
872 self.assertEqual(get_fmt(Decimal('12.7'), en_US), '12.7')
873 self.assertEqual(get_fmt(Decimal('12.7'), fr_FR), '12,7')
874 self.assertEqual(get_fmt(Decimal('12.7'), ru_RU), '12,7')
875 self.assertEqual(get_fmt(Decimal('12.7'), crazy), '1-2&7')
911 # locale with wide char separator and decimal point
917 self.skipTest('inappropriate decimal point separator'
923 self.assertEqual(format(Decimal('100000000.123'), 'n'),
932 d1 = Decimal('-11.1')
933 d2 = Decimal('22.2')
936 self.assertEqual(d1+d2, Decimal('11.1'))
937 self.assertEqual(d2+d1, Decimal('11.1'))
941 self.assertEqual(c, Decimal('-6.1'))
946 self.assertEqual(c, Decimal('-6.1'))
949 #inline with decimal
951 self.assertEqual(d1, Decimal('11.1'))
955 self.assertEqual(d1, Decimal('16.1'))
959 d1 = Decimal('-11.1')
960 d2 = Decimal('22.2')
963 self.assertEqual(d1-d2, Decimal('-33.3'))
964 self.assertEqual(d2-d1, Decimal('33.3'))
968 self.assertEqual(c, Decimal('-16.1'))
973 self.assertEqual(c, Decimal('16.1'))
976 #inline with decimal
978 self.assertEqual(d1, Decimal('-33.3'))
982 self.assertEqual(d1, Decimal('-38.3'))
986 d1 = Decimal('-5')
987 d2 = Decimal('3')
990 self.assertEqual(d1*d2, Decimal('-15'))
991 self.assertEqual(d2*d1, Decimal('-15'))
995 self.assertEqual(c, Decimal('-25'))
1000 self.assertEqual(c, Decimal('-25'))
1003 #inline with decimal
1005 self.assertEqual(d1, Decimal('-15'))
1009 self.assertEqual(d1, Decimal('-75'))
1013 d1 = Decimal('-5')
1014 d2 = Decimal('2')
1017 self.assertEqual(d1/d2, Decimal('-2.5'))
1018 self.assertEqual(d2/d1, Decimal('-0.4'))
1022 self.assertEqual(c, Decimal('-1.25'))
1027 self.assertEqual(c, Decimal('-0.8'))
1030 #inline with decimal
1032 self.assertEqual(d1, Decimal('-2.5'))
1036 self.assertEqual(d1, Decimal('-0.625'))
1040 d1 = Decimal('5')
1041 d2 = Decimal('2')
1044 self.assertEqual(d1//d2, Decimal('2'))
1045 self.assertEqual(d2//d1, Decimal('0'))
1049 self.assertEqual(c, Decimal('1'))
1054 self.assertEqual(c, Decimal('1'))
1057 #inline with decimal
1059 self.assertEqual(d1, Decimal('2'))
1063 self.assertEqual(d1, Decimal('1'))
1067 d1 = Decimal('5')
1068 d2 = Decimal('2')
1071 self.assertEqual(d1**d2, Decimal('25'))
1072 self.assertEqual(d2**d1, Decimal('32'))
1076 self.assertEqual(c, Decimal('625'))
1081 self.assertEqual(c, Decimal('16807'))
1084 #inline with decimal
1086 self.assertEqual(d1, Decimal('25'))
1090 self.assertEqual(d1, Decimal('390625'))
1094 d1 = Decimal('5')
1095 d2 = Decimal('2')
1098 self.assertEqual(d1%d2, Decimal('1'))
1099 self.assertEqual(d2%d1, Decimal('2'))
1103 self.assertEqual(c, Decimal('1'))
1108 self.assertEqual(c, Decimal('2'))
1111 #inline with decimal
1113 self.assertEqual(d1, Decimal('1'))
1117 self.assertEqual(d1, Decimal('1'))
1121 d1 = Decimal('5')
1122 d2 = Decimal('2')
1126 self.assertEqual(p, Decimal('2'))
1127 self.assertEqual(q, Decimal('1'))
1133 self.assertEqual(p, Decimal('1'))
1134 self.assertEqual(q, Decimal('1'))
1140 self.assertEqual(p, Decimal('1'))
1141 self.assertEqual(q, Decimal('2'))
1146 self.assertEqual(+Decimal(45), Decimal(+45)) # +
1147 self.assertEqual(-Decimal(45), Decimal(-45)) # -
1148 self.assertEqual(abs(Decimal(45)), abs(Decimal(-45))) # abs
1159 n = Decimal('NaN')
1160 s = Decimal('sNaN')
1161 i = Decimal('Inf')
1162 f = Decimal('2')
1203 d = Decimal(1).copy_sign(Decimal(-2))
1205 self.assertEqual(Decimal(1).copy_sign(-2), d)
1206 self.assertRaises(TypeError, Decimal(1).copy_sign, '-2')
1211 d1 = Decimal(1)
1212 d3 = Decimal(3)
1218 cls.assertEqual(test1, Decimal('0.3333333333333333333333333333'))
1219 cls.assertEqual(test2, Decimal('0.3333333333333333333333333333'))
1222 d1 = Decimal(1)
1223 d3 = Decimal(3)
1231 cls.assertEqual(test1, Decimal('0.3333333333333333333333333333'))
1232 cls.assertEqual(test2, Decimal('0.333333333333333333'))
1237 '''Unit tests for Use of Context cases in Decimal.'''
1260 '''Unit tests for Usability cases of Decimal.'''
1264 da = Decimal('23.42')
1265 db = Decimal('23.42')
1266 dc = Decimal('45')
1281 #a Decimal and an int
1289 #a Decimal and uncomparable
1296 a = map(Decimal, xrange(100))
1304 self.assertFalse(Decimal(1) < None)
1305 self.assertTrue(Decimal(1) > None)
1308 da = Decimal('0.25')
1309 db = Decimal('3.0')
1322 self.assertNotEqual(0.1, Decimal('0.1'))
1325 d = Decimal('43.24')
1333 hash(Decimal(23))
1334 hash(Decimal('Infinity'))
1335 hash(Decimal('-Infinity'))
1336 hash(Decimal('nan123'))
1337 hash(Decimal('-NaN'))
1339 test_values = [Decimal(sign*(2**m + n))
1345 Decimal("-0"), # zeros
1346 Decimal("0.00"),
1347 Decimal("-0.000"),
1348 Decimal("0E10"),
1349 Decimal("-0E12"),
1350 Decimal("10.0"), # negative exponent
1351 Decimal("-23.00000"),
1352 Decimal("1230E100"), # positive exponent
1353 Decimal("-4.5678E50"),
1356 Decimal(2**64 + 2**32 - 1),
1359 Decimal("1.634E100"),
1360 Decimal("90.697E100"),
1361 Decimal("188.83E100"),
1362 Decimal("1652.9E100"),
1363 Decimal("56531E100"),
1371 self.assertEqual(hash(Decimal(23)), hash(23))
1372 self.assertRaises(TypeError, hash, Decimal('sNaN'))
1373 self.assertTrue(hash(Decimal('Inf')))
1374 self.assertTrue(hash(Decimal('-Inf')))
1376 # check that the hashes of a Decimal float match when they
1382 d = Decimal(s)
1389 x = Decimal("123456789.1")
1404 d1 = Decimal('15.32')
1405 d2 = Decimal('28.5')
1415 #between Decimal and long
1423 self.assertFalse(Decimal(0))
1425 self.assertTrue(Decimal('0.372'))
1430 d = Decimal('15.32')
1432 self.assertEqual(repr(d), "Decimal('15.32')") # repr
1439 d = Decimal(u)
1447 d1 = Decimal('66')
1448 d2 = Decimal('15.32')
1463 # Test conversions of decimal NANs to float.
1466 f = float(Decimal(s))
1471 d = Decimal(s)
1477 d = Decimal( (0, (0,), 0) )
1481 d = Decimal( (1, (4, 5), 0) )
1485 d = Decimal( (0, (4, 5, 3, 4), -2) )
1489 d = Decimal( (1, (4, 3, 4, 9, 1, 3, 5, 3, 4), -25) )
1495 d = Decimal(0)
1499 d = Decimal(-45)
1503 d = Decimal("-4.34913534E-17")
1507 d = Decimal("Infinity")
1511 d = Decimal( (0, (0, 0, 4, 0, 5, 3, 4), -2) )
1513 d = Decimal( (1, (0, 0, 0), 37) )
1515 d = Decimal( (1, (), 37) )
1519 d = Decimal( (0, (0, 0, 4, 0, 5, 3, 4), 'n') )
1521 d = Decimal( (1, (0, 0, 0), 'N') )
1523 d = Decimal( (1, (), 'n') )
1527 d = Decimal( (0, (4, 5, 3, 4), 'F') )
1529 d = Decimal( (1, (0, 2, 7, 1), 'F') )
1535 d1 = Decimal('-25e55')
1536 b1 = Decimal('-25e55')
1537 d2 = Decimal('33e+33')
1538 b2 = Decimal('33e+33')
1555 Decimal(d1)
1608 # Different behaviours when subclassing Decimal
1610 class MyDecimal(Decimal):
1616 self.assertIs(type(d), Decimal)
1619 self.assertIs(type(d), Decimal)
1624 self.assertEqual(str(Decimal(0).sqrt()),
1625 str(c.sqrt(Decimal(0))))
1628 # Check that methods taking a second Decimal argument will
1629 # always accept an integer in place of a Decimal.
1630 self.assertEqual(Decimal(4).compare(3),
1631 Decimal(4).compare(Decimal(3)))
1632 self.assertEqual(Decimal(4).compare_signal(3),
1633 Decimal(4).compare_signal(Decimal(3)))
1634 self.assertEqual(Decimal(4).compare_total(3),
1635 Decimal(4).compare_total(Decimal(3)))
1636 self.assertEqual(Decimal(4).compare_total_mag(3),
1637 Decimal(4).compare_total_mag(Decimal(3)))
1638 self.assertEqual(Decimal(10101).logical_and(1001),
1639 Decimal(10101).logical_and(Decimal(1001)))
1640 self.assertEqual(Decimal(10101).logical_or(1001),
1641 Decimal(10101).logical_or(Decimal(1001)))
1642 self.assertEqual(Decimal(10101).logical_xor(1001),
1643 Decimal(10101).logical_xor(Decimal(1001)))
1644 self.assertEqual(Decimal(567).max(123),
1645 Decimal(567).max(Decimal(123)))
1646 self.assertEqual(Decimal(567).max_mag(123),
1647 Decimal(567).max_mag(Decimal(123)))
1648 self.assertEqual(Decimal(567).min(123),
1649 Decimal(567).min(Decimal(123)))
1650 self.assertEqual(Decimal(567).min_mag(123),
1651 Decimal(567).min_mag(Decimal(123)))
1652 self.assertEqual(Decimal(567).next_toward(123),
1653 Decimal(567).next_toward(Decimal(123)))
1654 self.assertEqual(Decimal(1234).quantize(100),
1655 Decimal(1234).quantize(Decimal(100)))
1656 self.assertEqual(Decimal(768).remainder_near(1234),
1657 Decimal(768).remainder_near(Decimal(1234)))
1658 self.assertEqual(Decimal(123).rotate(1),
1659 Decimal(123).rotate(Decimal(1)))
1660 self.assertEqual(Decimal(1234).same_quantum(1000),
1661 Decimal(1234).same_quantum(Decimal(1000)))
1662 self.assertEqual(Decimal('9.123').scaleb(-100),
1663 Decimal('9.123').scaleb(Decimal(-100)))
1664 self.assertEqual(Decimal(456).shift(-1),
1665 Decimal(456).shift(Decimal(-1)))
1667 self.assertEqual(Decimal(-12).fma(Decimal(45), 67),
1668 Decimal(-12).fma(Decimal(45), Decimal(67)))
1669 self.assertEqual(Decimal(-12).fma(45, 67),
1670 Decimal(-12).fma(Decimal(45), Decimal(67)))
1671 self.assertEqual(Decimal(-12).fma(45, Decimal(67)),
1672 Decimal(-12).fma(Decimal(45), Decimal(67)))
1678 self.assertTrue(issubclass(Decimal, numbers.Number))
1679 self.assertFalse(issubclass(Decimal, numbers.Real))
1680 self.assertIsInstance(Decimal(0), numbers.Number)
1681 self.assertNotIsInstance(Decimal(0), numbers.Real)
1684 d = Decimal('-3.141590000')
1694 self.assertEqual(int(Decimal(s)), int(float(s)))
1696 d = Decimal(s)
1698 self.assertEqual(Decimal(int(d)), r)
1700 self.assertRaises(ValueError, int, Decimal('-nan'))
1701 self.assertRaises(ValueError, int, Decimal('snan'))
1702 self.assertRaises(OverflowError, int, Decimal('inf'))
1703 self.assertRaises(OverflowError, int, Decimal('-inf'))
1705 self.assertRaises(ValueError, long, Decimal('-nan'))
1706 self.assertRaises(ValueError, long, Decimal('snan'))
1707 self.assertRaises(OverflowError, long, Decimal('inf'))
1708 self.assertRaises(OverflowError, long, Decimal('-inf'))
1714 self.assertEqual(int(Decimal(s)), int(float(s)))
1716 d = Decimal(s)
1718 self.assertEqual(Decimal(math.trunc(d)), r)
1722 class MyDecimal(Decimal):
1735 str(Decimal('NaN')))
1737 str(Decimal('Infinity')))
1739 str(Decimal('-Infinity')))
1749 Decimal('3.1415')
1754 Decimal('3.1416')
1763 "Decimal('-0')")
1765 "Decimal('1')")
1767 "Decimal('10')")
1781 self.assertIn(Decimal(10), ['a', 1.0, Decimal(10), (1,2), {}])
1782 self.assertNotIn(Decimal(10), ['a', 1.0, (1,2), {}])
1794 d = c.abs(Decimal(-1))
1800 d = c.add(Decimal(1), Decimal(1))
1802 self.assertEqual(c.add(Decimal(1), 1), d)
1803 self.assertEqual(c.add(1, Decimal(1)), d)
1809 d = c.compare(Decimal(1), Decimal(1))
1811 self.assertEqual(c.compare(Decimal(1), 1), d)
1812 self.assertEqual(c.compare(1, Decimal(1)), d)
1818 d = c.compare_signal(Decimal(1), Decimal(1))
1820 self.assertEqual(c.compare_signal(Decimal(1), 1), d)
1821 self.assertEqual(c.compare_signal(1, Decimal(1)), d)
1827 d = c.compare_total(Decimal(1), Decimal(1))
1829 self.assertEqual(c.compare_total(Decimal(1), 1), d)
1830 self.assertEqual(c.compare_total(1, Decimal(1)), d)
1836 d = c.compare_total_mag(Decimal(1), Decimal(1))
1838 self.assertEqual(c.compare_total_mag(Decimal(1), 1), d)
1839 self.assertEqual(c.compare_total_mag(1, Decimal(1)), d)
1845 d = c.copy_abs(Decimal(-1))
1851 d = c.copy_decimal(Decimal(-1))
1857 d = c.copy_negate(Decimal(-1))
1863 d = c.copy_sign(Decimal(1), Decimal(-2))
1865 self.assertEqual(c.copy_sign(Decimal(1), -2), d)
1866 self.assertEqual(c.copy_sign(1, Decimal(-2)), d)
1872 d = c.divide(Decimal(1), Decimal(2))
1874 self.assertEqual(c.divide(Decimal(1), 2), d)
1875 self.assertEqual(c.divide(1, Decimal(2)), d)
1881 d = c.divide_int(Decimal(1), Decimal(2))
1883 self.assertEqual(c.divide_int(Decimal(1), 2), d)
1884 self.assertEqual(c.divide_int(1, Decimal(2)), d)
1890 d = c.divmod(Decimal(1), Decimal(2))
1892 self.assertEqual(c.divmod(Decimal(1), 2), d)
1893 self.assertEqual(c.divmod(1, Decimal(2)), d)
1899 d = c.exp(Decimal(10))
1905 d = c.fma(Decimal(2), Decimal(3), Decimal(4))
1907 self.assertEqual(c.fma(Decimal(2), 3, 4), d)
1908 self.assertEqual(c.fma(2, Decimal(3), 4), d)
1909 self.assertEqual(c.fma(2, 3, Decimal(4)), d)
1910 self.assertEqual(c.fma(Decimal(2), Decimal(3), 4), d)
1917 d = c.is_finite(Decimal(10))
1923 d = c.is_infinite(Decimal(10))
1929 d = c.is_nan(Decimal(10))
1935 d = c.is_normal(Decimal(10))
1941 d = c.is_qnan(Decimal(10))
1947 d = c.is_signed(Decimal(10))
1953 d = c.is_snan(Decimal(10))
1959 d = c.is_subnormal(Decimal(10))
1965 d = c.is_zero(Decimal(10))
1971 d = c.ln(Decimal(10))
1977 d = c.log10(Decimal(10))
1983 d = c.logb(Decimal(10))
1989 d = c.logical_and(Decimal(1), Decimal(1))
1991 self.assertEqual(c.logical_and(Decimal(1), 1), d)
1992 self.assertEqual(c.logical_and(1, Decimal(1)), d)
1998 d = c.logical_invert(Decimal(1000))
2004 d = c.logical_or(Decimal(1), Decimal(1))
2006 self.assertEqual(c.logical_or(Decimal(1), 1), d)
2007 self.assertEqual(c.logical_or(1, Decimal(1)), d)
2013 d = c.logical_xor(Decimal(1), Decimal(1))
2015 self.assertEqual(c.logical_xor(Decimal(1), 1), d)
2016 self.assertEqual(c.logical_xor(1, Decimal(1)), d)
2022 d = c.max(Decimal(1), Decimal(2))
2024 self.assertEqual(c.max(Decimal(1), 2), d)
2025 self.assertEqual(c.max(1, Decimal(2)), d)
2031 d = c.max_mag(Decimal(1), Decimal(2))
2033 self.assertEqual(c.max_mag(Decimal(1), 2), d)
2034 self.assertEqual(c.max_mag(1, Decimal(2)), d)
2040 d = c.min(Decimal(1), Decimal(2))
2042 self.assertEqual(c.min(Decimal(1), 2), d)
2043 self.assertEqual(c.min(1, Decimal(2)), d)
2049 d = c.min_mag(Decimal(1), Decimal(2))
2051 self.assertEqual(c.min_mag(Decimal(1), 2), d)
2052 self.assertEqual(c.min_mag(1, Decimal(2)), d)
2058 d = c.minus(Decimal(10))
2064 d = c.multiply(Decimal(1), Decimal(2))
2066 self.assertEqual(c.multiply(Decimal(1), 2), d)
2067 self.assertEqual(c.multiply(1, Decimal(2)), d)
2073 d = c.next_minus(Decimal(10))
2079 d = c.next_plus(Decimal(10))
2085 d = c.next_toward(Decimal(1), Decimal(2))
2087 self.assertEqual(c.next_toward(Decimal(1), 2), d)
2088 self.assertEqual(c.next_toward(1, Decimal(2)), d)
2094 d = c.normalize(Decimal(10))
2100 self.assertEqual(c.number_class(123), c.number_class(Decimal(123)))
2101 self.assertEqual(c.number_class(0), c.number_class(Decimal(0)))
2102 self.assertEqual(c.number_class(-45), c.number_class(Decimal(-45)))
2106 d = c.power(Decimal(1), Decimal(4), Decimal(2))
2108 self.assertEqual(c.power(Decimal(1), 4, 2), d)
2109 self.assertEqual(c.power(1, Decimal(4), 2), d)
2110 self.assertEqual(c.power(1, 4, Decimal(2)), d)
2111 self.assertEqual(c.power(Decimal(1), Decimal(4), 2), d)
2118 d = c.plus(Decimal(10))
2124 d = c.quantize(Decimal(1), Decimal(2))
2126 self.assertEqual(c.quantize(Decimal(1), 2), d)
2127 self.assertEqual(c.quantize(1, Decimal(2)), d)
2133 d = c.remainder(Decimal(1), Decimal(2))
2135 self.assertEqual(c.remainder(Decimal(1), 2), d)
2136 self.assertEqual(c.remainder(1, Decimal(2)), d)
2142 d = c.remainder_near(Decimal(1), Decimal(2))
2144 self.assertEqual(c.remainder_near(Decimal(1), 2), d)
2145 self.assertEqual(c.remainder_near(1, Decimal(2)), d)
2151 d = c.rotate(Decimal(1), Decimal(2))
2153 self.assertEqual(c.rotate(Decimal(1), 2), d)
2154 self.assertEqual(c.rotate(1, Decimal(2)), d)
2160 d = c.sqrt(Decimal(10))
2166 d = c.same_quantum(Decimal(1), Decimal(2))
2168 self.assertEqual(c.same_quantum(Decimal(1), 2), d)
2169 self.assertEqual(c.same_quantum(1, Decimal(2)), d)
2175 d = c.scaleb(Decimal(1), Decimal(2))
2177 self.assertEqual(c.scaleb(Decimal(1), 2), d)
2178 self.assertEqual(c.scaleb(1, Decimal(2)), d)
2184 d = c.shift(Decimal(1), Decimal(2))
2186 self.assertEqual(c.shift(Decimal(1), 2), d)
2187 self.assertEqual(c.shift(1, Decimal(2)), d)
2193 d = c.subtract(Decimal(1), Decimal(2))
2195 self.assertEqual(c.subtract(Decimal(1), 2), d)
2196 self.assertEqual(c.subtract(1, Decimal(2)), d)
2202 d = c.to_eng_string(Decimal(10))
2208 d = c.to_sci_string(Decimal(10))
2214 d = c.to_integral_exact(Decimal(10))
2220 d = c.to_integral_value(Decimal(10))
2260 (context._apply, [Decimal("100E-1000000009")]),
2261 (context.sqrt, [Decimal(2)]),
2262 (context.add, [Decimal("1.23456789"), Decimal("9.87654321")]),
2263 (context.multiply, [Decimal("1.23456789"), Decimal("9.87654321")]),
2264 (context.subtract, [Decimal("1.23456789"), Decimal("9.87654321")]),
2303 Runs all arithmetic tests if arith is True or if the "decimal" resource
2309 TEST_ALL = arith if arith is not None else is_resource_enabled('decimal')
2346 import decimal as DecimalModule