Normally, we know that 0.5-0.4 is 0.1. But when I run the code, I get some wrong calculation or the result is not clear to me. Please, may you explain how compiler handle the floating point calculation in Java.
System.out.println(0.5-.4); // my expected output 0.1
System.out.println(0.5f-.4f); // my expected output 0.1
Output:
0.09999999999999998
0.099999994