How to avoid floating point precision errors with floats or doubles in Java?
There is a no exact representation of 0.1 as a float or double. Because of this representation error the results are slightly different from what you expected. A couple of approaches you can use: When using the double type, only display as many digits as you need. When checking for equality allow for a small … Read more