#include <stdio.h>
main()
{
float x;
x = (float)3.3==3.3;
printf("%f",x);
x=(float)3.5==3.5;
printf("\n%f",x);
}
i’m confused with
in the first case answer is 0.000
and in the second case answer is 1.00
can anyone explain ?
By default, the right side numbers are typecasted to doubles not floats. In order for both cases to print 1, you need to either change the float typecast to double or typecast the second number as a float:
or: