0

9.99%5=4.99 but 9.99999999999999999999%5=0, why?

In Python(3.6.4) if the input is 9.99%5 the output is 4.99, and so on for about 15 9s after the decimal point, but if the input is 9.99999999999999999999%5 the output is 0.0. Why is this happening and why exactly after this number of decimals?

16th Jan 2018, 12:35 PM
Filip Ilașcă
Filip Ilașcă - avatar
1 Réponse
- 1
Since you cannot find a real number between 9.999... (repeating nines) and 10, they are the same number. They're just a different way of representing the same number. Reference https://www.physicsforums.com/threads/9-99999-10.212487/
16th Jan 2018, 1:02 PM
Toni Isotalo
Toni Isotalo - avatar