3 Antworten
+ 5
Floats are represented as binary fractions in computing. There is only a limited precision to what extent this representation can be accurate.
What is even more important, a boolean test of:
.1999999999999996 == 0.2
might give you True as a result. That's just the way it is.
If you are not ok with how this looks on the screen, try using .format string method to show only one, two or how many you want decimal digits.
+ 1
https://docs.python.org/3.5/tutorial/floatingpoint.html