I've found an interesting case where the same C++ code yields different results on different system.
#include <cstdio>
int main()
{
int a=20, b=14;
if(a*1.0/b*(a+1)/(b+1)==2) printf("YES!");
else printf("NO!");
}
Compiled on Ubuntu Linux 12.04 using GCC 4.6.3 it outputs YES!
Compiled on Windows 7 using GCC 4.6.2 it outputs NO!
However, using:
double c = a*1.0/b*(a+1)/(b+1);
if (c==2) printf("YES!");
...
will return YES! on both machines.
Any ideas why this difference emerges? Is this caused by compiler version mismatch (pathlevel version number shouldn't matter THAT much)? And why does it actually output NO! on the Windows machine, while this condition is obviously true?