Welcome to the Treehouse Community
Looking to learn something new?
Sandra OlmesdahlFront End Web Development Techdegree Student 2,522 Points
Why are float calculations inaccurate?
Quick one - how come the question 0.1 + 0.1 + 0.1 - 0.3 does not come up with an exact answer? Surely (as you point out), this inaccuracy can have some pretty serious side effects? Is this due to the original parameters around the Python language, or is it just one of "those" idiosyncrasies?
Jennifer NordellTreehouse Teacher
Hi there! I'm not sure what you mean by "those" idiosyncrasies, but the topic you just touched upon is very likely bigger than you think and by no means exclusive to Python. Among other things, you will need a good foundation in math and number theory to understand the answer. But I might suggest this article from Oracle or this one.
The problem is not so much with Python or really any other computer language. The problem lies in the representation of the numbers themselves. Remember, at the end of all this everything is still just 0s and 1s. This is where the problem lies. You are representing a decimal value in binary form and some inaccuracy will occur as a result.
Hope this helps!