Lines Matching full:decimal
1 """Decimal fixed-point and floating-point arithmetic.
3 This is an implementation of decimal floating-point arithmetic based on
4 the General Decimal Arithmetic Specification:
6 http://speleotrove.com/decimal/decarith.html
12 Decimal floating point has finite precision with arbitrarily large bounds.
20 of 0.0; Decimal('1.00') % Decimal('0.1') returns the expected
21 Decimal('0.00')).
23 Here are some examples of using the decimal module:
25 >>> from decimal import *
27 >>> Decimal(0)
28 Decimal('0')
29 >>> Decimal('1')
30 Decimal('1')
31 >>> Decimal('-.0123')
32 Decimal('-0.0123')
33 >>> Decimal(123456)
34 Decimal('123456')
35 >>> Decimal('123.45e12345678')
36 Decimal('1.2345E+12345680')
37 >>> Decimal('1.33') + Decimal('1.27')
38 Decimal('2.60')
39 >>> Decimal('12.34') + Decimal('3.87') - Decimal('18.41')
40 Decimal('-2.20')
41 >>> dig = Decimal(1)
42 >>> print(dig / Decimal(3))
45 >>> print(dig / Decimal(3))
49 >>> print(Decimal(3).sqrt())
51 >>> print(Decimal(3) ** 123)
53 >>> inf = Decimal(1) / Decimal(0)
56 >>> neginf = Decimal(-1) / Decimal(0)
71 decimal.DivisionByZero: x / 0
76 >>> c.divide(Decimal(0), Decimal(0))
77 Decimal('NaN')
84 >>> print(c.divide(Decimal(0), Decimal(0)))
89 decimal.InvalidOperation: 0 / 0
94 >>> print(c.divide(Decimal(0), Decimal(0)))