doubles are not exact.
It is because there are infinite possible real numbers and only finite number of bits to represent these numbers.
have a look at: what every programmer should know about floating point arithmetic
More Related Contents:
- Retain precision with double in Java
- How to nicely format floating numbers to string without unnecessary decimal 0’s
- Double vs. BigDecimal?
- Float and double datatype in Java
- Convert float to double without losing precision
- Why does Math.round(0.49999999999999994) return 1?
- Java:Why should we use BigDecimal instead of Double in the real world? [duplicate]
- Double calculation producing odd result [duplicate]
- Why converting from float to double changes the value?
- What do F and D mean at the end of numeric literals?
- What is the inclusive range of float and double in Java?
- Why does adding 0.1 multiple times remain lossless?
- Java double precision sum trouble
- Loss of precision – int -> float or double
- Why can’t we use ‘==’ to compare two float or double numbers [duplicate]
- How many significant digits do floats and doubles have in java?
- Double decimal formatting in Java
- Moving decimal places over in a double
- When should I use the “strictfp” keyword in java?
- How can I truncate a double to only two decimal places in Java?
- Do any JVM’s JIT compilers generate code that uses vectorized floating point instructions?
- Convert double to BigDecimal and set BigDecimal Precision
- Double cannot be dereferenced?
- How do Java runtimes targeting pre-SSE2 processors implement floating-point basic operations?
- Why does integer division by zero 1/0 give error but floating point 1/0.0 returns “Inf”?
- Double division behaving wrongly
- Why is comparing floats inconsistent in Java?
- Java: Double Value Comparison
- Unexpected result in long/int division
- Long float-number output shows letters