While I was having fun with codes from Java Puzzlers(I don't have the book) I came across this piece of code
public static void main(String args[]) {
System.out.println(2.00 - 1.10);
}
Output is
0.8999999999999999
When I tried changing the code to
2.00d - 1.10d
still I get the same output as 0.8999999999999999
For,2.00d - 1.10f
Output is 0.8999999761581421
For,2.00f - 1.10d
Output is 0.8999999999999999
For,2.00f - 1.10f
Output is 0.9
Why din't I get the output as 0.9
in the first place? I could not make any heads or tails out of this? Can somebody articulate this?