the inexactness is not problem specific to python--all programming languages have this problem with floating-point numbers python produces much more sensible-looking output - - ( - when python outputs floating-point numberin most cases it uses david gay' algorithm this outputs the fewest possible digits without losing any accuracy although this produces nicer outputit doesn' change the fact that computers (no matter what computer language is usedeffectively store floating-point numbers as approximations if we need really high precision there are two approaches we can take one approach is to use ints--for exampleworking in terms of pennies or tenths of penny or similar--and scale the numbers when necessary this requires us to be quite carefulespecially when dividing or taking percentages the other approach is to use python' decimal decimal numbers from the decimal module these perform calculations that are accurate to the level of precision we specify (by defaultto decimal placesand can represent periodic numbers like exactlybut processing is lot slower than with floats because of their accuracydecimal decimal numbers are suitable for financial calculations mixed mode arithmetic is supported such that using an int and float produces floatand using float and complex produces complex because decimal decimals are of fixed precision they can be used only with other decimal decimals and with intsin the latter case producing decimal decimal result if an operation is attempted using incompatible typesa typeerror exception is raised floating-point numbers |all the numeric operators and functions in table ( can be used with floatsincluding the augmented assignment versions the float data type can be called as function--with no arguments it returns with float argument it returns copy of the argumentand with any other argument it attempts to convert the given object to float when used for conversions string argument can be giveneither using simple decimal notation or using exponential notation it is possible that nan ("not number"or "infinitymay be produced by calculation involving floats--unfortunately the behavior is not consistent across implementations and may differ depending on the system' underlying math library here is simple function for comparing floats for equality to the limit of the machine' accuracy