If you really care about precision, you should use BigDecimal
https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigDecimal.html
More Related Contents:
- Retain precision with double in Java
- Why converting from float to double changes the value?
- Why does adding 0.1 multiple times remain lossless?
- Loss of precision – int -> float or double
- Division of integers in Java [duplicate]
- How many significant digits do floats and doubles have in java?
- Why does integer division code give the wrong answer? [duplicate]
- Convert float to double without losing precision
- When should I use the “strictfp” keyword in java?
- How to check that a string is parseable to a double? [duplicate]
- comparing float/double values using == operator
- Why does (360 / 24) / 60 = 0 … in Java
- Java: Why do you need to specify an ‘f’ in a float literal? [duplicate]
- What is the difference between the float and integer data type when the size is the same?
- Double calculation producing odd result [duplicate]
- Do any JVM’s JIT compilers generate code that uses vectorized floating point instructions?
- Why does changing the sum order returns a different result?
- BigDecimal, precision and scale
- How do Java runtimes targeting pre-SSE2 processors implement floating-point basic operations?
- How do I check if a zero is positive or negative?
- ArithmeticException thrown during BigDecimal.divide
- Java double precision sum trouble
- Are the bit patterns of NaNs really hardware-dependent?
- Why is comparing floats inconsistent in Java?
- Long float-number output shows letters
- How to convert IEEE-11073 16-bit SFLOAT to simple float in Java?
- How can I convert integer into float in Java?
- How to convert pcm samples in byte array as floating point numbers in the range -1.0 to 1.0 and back?
- Is checking a double for equality ever safe?
- How to convert hex string to float in Java?