In both cases your code is comparing a float value to a double, as the compiler sees 3.2f as a float and 3.2 (without the f) as a double. The float data type is a single-precision 32-bit The double data type is a double-precision 64-bit You shouldn't ever compare floats or doubles for equality, you can't really guarantee that the number you assign to the float or double is exact. It's the same for float and double - both are binary floating point types, but double has more precision than float. By default java assumes a manually specified number to be a double, as a double would more precisely cover more numbers that you could type in. You have to cast between doubles and float explicitly. | 0 |
By: [email protected] On: Fri Jul 04 17:40:48 IST 2014 0 392 0 | 392 |
Are You Satisfied :2Yes1No |
A float is a 32 bit IEEE 754 floating point. A double is a 64 bit IEEE 754 floating point. so it is just a matter of precision because neither of the fraction portions .8 and .65 have a terminating binary representation, so there is some rounding error. the double has more precision so it has slightly less rounding error. | 0 |
By: [email protected] On: Sat Jul 05 13:18:28 IST 2014 0 0 0 | 0 |
Are You Satisfied :1Yes2No |
We can represent float variable value up to 7 digits after decimal point, whereas double value can be represent up to 15 digits after decimal point. | 0 |
By: [email protected] On: Tue Nov 07 12:44:28 IST 2017 0 0 0 | 0 |
Are You Satisfied :0Yes0No |