Decimal problem when multiplying times ten
in
Programming Questions
•
10 months ago
I searched around for a while and did not find this problem already reported. Can anyone please tell me why...
...returns 0.049999997 and not 0.05? If I change the 1 to 5, then the output is (correctly) 0.25, but any other integer between 1 and 9 returns something like 0.049999997. This is not a problem if I change the 10 to a 1 or 100.
I am running Processing 1.5.1.
- println(0.5 * 1 * 10 * 0.01);
...returns 0.049999997 and not 0.05? If I change the 1 to 5, then the output is (correctly) 0.25, but any other integer between 1 and 9 returns something like 0.049999997. This is not a problem if I change the 10 to a 1 or 100.
I am running Processing 1.5.1.
1