Possible Duplicate:
Java floating point arithmetic
Hi All, I was just reading a book and i came across this example which gave different outputs. Can somebody explain to me why.
public class Test {
public static void main(String[] args) {
double x = 0.3 - 0.2;
double y = 0.2 - 0.1;
System.out.println(x);
System.out.println(y);
System.out.println(y == x);
}
}
Output is : 0.09999999999999998
0.1
false