+ 3
0.1+0.2 = 0.3 ? what happen ?
i try 0.1 + 0.2 but answer is 0.30000000000000004
5 Answers
+ 7
The second tag is Python3 ^^
This is due to inaccuracy of float number stored in binary:
https://en.m.wikipedia.org/wiki/Floating-point_arithmetic#Accuracy_problems
http://effbot.org/pyfaq/why-are-floating-point-calculations-so-inaccurate.htm
http://stackoverflow.com/questions/2100490/floating-point-inaccuracy-examples
https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
+ 1
That's why you should use BigDecimal instead float or double when you work with currency.
+ 1
The first tag is Java đ