It should be noted that the native double precision representation of floating-point numbers leads to some unexpected results. For example, consider the following:
>>> 1-0.9
0.09999999999999998
>>> 1-0.9==.1
False
This is a result of the fact that most decimal fractions are not exactly representable as a binary fraction, which is how most underlying hardware represents floating-point numbers. For algorithms or applications where this may be an issue, Python provides a decimal module. This module allows for the exact representation of decimal numbers and facilitates greater control of properties, such as rounding behavior, number of significant digits, and precision. It defines two objects, a Decimal type, representing decimal numbers, and a Context type, representing various computational parameters such as precision, rounding, and error handling...