Most fractional numbers can not be accurately represented by a double type. For example, 0.1 in the binary form is represented as an infinite binary fraction, as in the computer memory only a limited number of places is stored, the infinite "tail" is discarded and the resulting value slightly differs from 0.1.
This way of representing the fractional numbers is included in the output to the screen and displays the "correct" value.
If you use another way to represent fractional numbers, you can get a different result.
For example, the command System.out.println(new BigDecimal(0.1)); will bring real insight of the number in the memory: 0.1000000000000000055511151231257827021181583404541015625