Retain precision with double in Java
As others have mentioned, you’ll probably want to use the BigDecimal class, if you want to have an exact representation of 11.4. Now, a little explanation into why this is happening: The float and double primitive types in Java are floating point numbers, where the number is stored as a binary representation of a fraction … Read more