I got a question to find the output of below code snippet
int main(int argc, char const *argv[])
{
float a=0.7;
if(a<0.7)
std::cout<<"yes";
else
std::cout<<"no";
}
At first look, like everyone my answer was "no" because 0.7 is not less than 0.7. But when i run it, output was "yes". I found an explanation about this which says C++ internally takes 0.7 as double value and here actually it is checking whether 0.700 < 0.7ff which will be true. So i tried the same with another value 0.5. But then this program had "no" as output. Why it is so? Doesn't it really check whether 0.500<0.5ff?, or all my understanding about it is wrong?