this is result of the fact that most decimal fractions are not exactly representable as binary fractionwhich is how most underlying hardware represents floating point numbers for algorithms or applications where this may be an issuepython provides decimal module this module allows for the exact representation of decimal numbers and facilitates greater control properties such as rounding behaviornumber of significant digitsand precision it defines two objectsa decimal typerepresenting decimal numbersand context typerepresenting various computational parameters such as precisionroundingand error handling an example of its usage can be seen in the following snippethere we have created global context and set the precision to the decimal object can be treated pretty much as you would treat an int or float they are subject to all the same mathematical operations and can be used as dictionary keysplaced in setsand so on in additiondecimal objects also have several methods for mathematical operationssuch as natural exponentsx exp()natural logarithmsx ln()and base logarithmsx log (python also has fractions module that implements rational number type the following example shows several ways to create fractionsit is also worth mentioning here the numpy extension this has types for mathematical objects such as arraysvectorsand matrixesand capabilities for linear algebracalculation of fourier transformseigenvectorslogical operationsand much more