1
double x = 0.54;
double y = 0.06;
System.out.println("Dimmer: " + (x+y));

gives me the output:

Dimmer: 0.6000000000000001

Could someone elaborate this for me.

miniwolf
  • 339
  • 1
  • 4
  • 19
  • 1
    You are seeing a rounding error. To avoid seeing this, use BigDecimal, or round your result. e.g. `System.out.printf("Dimmer: %.2f%n", x + y);` – Peter Lawrey Dec 12 '14 at 14:14

0 Answers0