I have two values (Double
type).
a = 1
b = 1.11
When I add them together the result is 2.1100000000000003
. Why?
There is no problem with 1 + 1.1
Asked
Active
Viewed 36 times
0

Cœur
- 37,241
- 25
- 195
- 267

Marcin Królikowski
- 39
- 1
- 7
-
[What every computer scientist should know about floating-point arithmetic](https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html). – Phylogenesis Nov 30 '16 at 08:42
-
This is a good question but there is a duplicate: do study it carefully. Note that Java uses IEEE754 floating point. – Bathsheba Nov 30 '16 at 08:42