Since unrealized floating point literals are doubled, and rounding means that even small literals can take different values ββwhen rounding to float and double. This can be observed in the following example:
float f = (float) 0.67; if(f == 0.67) System.out.print("yes"); else System.out.print("no");
This will print no , because 0.67 has a different meaning when rounding to float than when rounding to double. On the other hand:
float f = (float) 0.67; if(f == 0.67f) System.out.print("yes"); else System.out.print("no");
& hellip; outputs yes .
EDIT
Second example:
if(0.67 == 0.67f) System.out.print("Equal"); else System.out.print("Not Equal");
Grijesh Chauhan Dec 31 '13 at 14:52 2012-12-31 14:52
source share