That is more digits than most people find useful, so Python keeps the number of digits manageable by displaying a rounded value instead >>> 1/10 0.1 Just remember, even though the printed result looks like the exact value of 1/10, the actual stored value is the nearest representable binary fraction. Interestingly, there are many different decimal numbers that share the same nearest approxi- mate binary fraction. For example, the numbers 0.1 and 0.10000000000000001 and 0. are all approximated by 3602879701896397 / 2 ** 55 . Since all of these decimal values share the same approximation, any one of them could be displayed while still preserving the invariant$_{eval(repr(x)) == x}$ . Historically, the Python prompt and built-in$_{repr()}$ function would choose the one with 17 significant digits,$_{0.}$ 10000000000000001 . Starting with Python 3.1, Python (on most systems) is now able to choose the shortest of these and simply display 0.1 . Note that this is in the very nature of binary floating-point: this is not a bug in Python, and it is not a bug in your code either. You’ll see the same kind of thing in all languages that support your hardware’s floating-point arithmetic (although some languages may not display the difference by default, or in all output modes). For more pleasant output, you may wish to use string formatting to produce a limited number of significant digits: >>> format(math.pi,'.12g ') # give 12 significant digits '3.14159265359' >>> format(math.pi,'.2f ') # give 2 digits after the point '3.14' >>> repr(math.pi) '3.141592653589793' >>> .1+.1+.1==.3 False It’s important to realize that this is, in a real sense, an illusion: you’re simply rounding the display of the true machine value. One illusion may beget another. For example, since 0.1 is not exactly 1/10, summing three values of 0.1 may not yield exactly 0.3, either: Also, since the 0.1 cannot get any closer to the exact value of 1/10 and 0.3 cannot get any closer to the exact value of 3/10, then pre-rounding with$_{round()}$ function cannot help: Though the numbers cannot be made closer to their intended exact values, the$_{round()}$ function can be useful for post-rounding so that results with inexact values become comparable to one another: Binary floating-point arithmetic holds many surprises like this. The problem with “0.1” is explained in precise detail below, in the “Representation Error” section. See The Perils of Floating Point for a more complete account of other common surprises. As that says near the end, “there are no easy answers.” Still, don’t be unduly wary of floating-point! The errors in Python float operations are inherited from the floating-point hardware, and on most machines are on the order of no more than 1 part in 2**53 per operation. That’s more than adequate for most tasks, but you do need to keep in mind that it’s not decimal arithmetic and that every float operation can suffer a new rounding error. Chapter 15. Floating Point Arithmetic: Issues and Limitations 100 >>> round(.1+.1+.1,10)==round(.3,10) True >>> round(.1,1)+round(.1,1)+round(.1,1)==round(.3,1) False