the last point merits elaboration as previewed briefly when we explored comparisonsfloating-point math is less than exact because of the limited space used to store values for examplethe following should yield zerobut it does not the result is close to zerobut there are not enough bits to be precise here - python on pythons prior to and printing the result to produce the user-friendly display format doesn' completely help eitherbecause the hardware related to floating-point math is inherently limited in terms of accuracy ( precisionthe following in gives the same result as the previous outputprint( - pythons howeverwith decimalsthe result can be dead-onfrom decimal import decimal decimal(' 'decimal(' 'decimal(' 'decimal(' 'decimal(' 'as shown herewe can make decimal objects by calling the decimal constructor function in the decimal module and passing in strings that have the desired number of decimal digits for the resulting object (using the str function to convert floating-point values to strings if neededwhen decimals of different precision are mixed in expressionspython converts up to the largest number of decimal digits automaticallydecimal(' 'decimal(' 'decimal(' 'decimal(' 'decimal(' 'in pythons and laterit' also possible to create decimal object from floatingpoint objectwith call of the form decimal decimal from_float( )and recent pythons allow floating-point numbers to be used directly the conversion is exact but can sometimes yield large default number of digitsunless they are fixed per the next sectiondecimal( decimal( decimal( decimal( decimal(' - 'in python and laterthe decimal module was also optimized to improve its performance radicallythe reported speedup for the new version is to xdepending on the type of program benchmarked setting decimal precision globally other tools in the decimal module can be used to set the precision of all decimal numbersarrange error handlingand more for instancea context object in this module allows for specifying precision (number of decimal digitsand rounding modes (down numeric types