The first time 0.30000000000000004 showed up on my screen I did what everyone does. I blamed Python. Then I blamed my keyboard. Then Python again, louder.
It's not Python. JavaScript prints the same number, and so does nearly every language on your machine, because nearly every language stores decimals the same way: as IEEE 754 doubles, a standard from 1985 that is older than most of the people complaining about it.
Where does the extra 4 come from?
Write one third as a decimal. You can't. You get 0.333 and then the 3s keep going until you run out of patience or paper, and whatever you eventually write down is close to a third but is not a third.
Binary has the same problem with different numbers. 0.1 in binary is 0.0001100110011..., the "0011" repeating forever.β¦