Today sumit brought a programm,and i realized that so easy it is to forget the basics while you are busy with advanced programming.
here is the programm snippet,
float a=0.7;
if(a<0.7)
{
printf("\n a<0.7\n");
}
else
{
printf("\n nope\n");
}
Hewre what i thought that it'd print 'a<0.7'
but no because it is treated 0.7 as 0 only,
to make it work you have to explicitly cast
0.7 as (float)0.7.
or use another folat variable and store 0.7 in that.
Looks like should go thru the basics again:-)
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment