float x=1.1;
if(x==1.1) //This condition evaluates to false, since a float is being compared to a double.
float x=1.25;
if(x==1.25) //This condition evaluates to true, since 1.25 is not a recurring binary number.
However, I want to know how a float
and a double
are actually compared?
Is the float
promoted to a double
(by adding leading 0s) and then compared?