Double parseDouble adding extra 0's when adding the numbers
android, double, java
Solution
Java uses IEEE floating point numbers for its `double` (and `float`) datatypes. A `double` has a lot of precision, but not infinite precision. Some numbers are only approximated.
In addition (no pun intended), adding numbers like this together compounds the floating point errors. Eventually the error is large enough to notice, such as with your issue here.
If you can accept a performance hit, then use `BigDecimal`, which is arbitrary precision.
Problem
I am running weird situation. I am counting the numbers using Double parseDouble. In some situation i am getting extra 0's for instance instead of 109.1 i am getting ... 109.10000001. I am trying to add string from json. Here is the line of code I am executing. ``` points = points + Double.parseDouble(x.points); ```