why when i print this code in print statement the output will be not correct.
System.out.println(3.15 - 3);
the output is:
0.1499999999999999
i think the output must be.
0.15
why when i print this code in print statement the output will be not correct.
System.out.println(3.15 - 3);
the output is:
0.1499999999999999
i think the output must be.
0.15
System.out.println((float)(3.15 - 3.0)); //the answer is 0.15
System.out.println(3.15f - 3); //the answer is 0.1500001
System.out.println(3.15 - 3.0); //the answer is 0.1499999999999999