Hello,
I have been programming for quite a while now, but the following behavior is one of the most weird ones I ever encountered. It really is annoying me, and I just can't get to the bottom of it. So, in short, the other day I was writing a very small program which calculates all possible solutions to a given problem. The program didn't work, and after some debugging, I was astonished that the following code just doesn't seem to work for some obscure reason. The problem is that nothing is written to the screen in the loop :
#include <iostream>
int main() {
for (double C=0.0; C<100.0; C+=0.1)
if (C==1.0)
std::cout << C << std::endl;
return 0;
}
The program always evaluates (C==1.0) as false. Why?