main()
{
float a=0.7;
if(a<0.7) cout<<"true" ;else cout<<"false";
}
problem---> it prints true .....
when 0.7 is replaced everywhere with 0.8 it displays false
again with 0.9 , it displays true..
typically only for 0.7 and 0.9 it gives different answer ,then the conventional logical answer..why so??
I do not remember the exact reason for the behavior in your code, it has got something to do with how floats are treated by the hardware.
Someone please elaborate.
thank you mrinal..
i think it is because the default datatype is double ..hence to do a proper comparison of float values,we have to specify it .
thanks.
I do not remember the exact reason for the behavior in your code, it has got something to do with how floats are treated by the hardware.
Someone please elaborate.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.