@vt_mruhlin said:
That's double with a capital D so I'm not sure what kind of carnage they've added, but for regular CPP implementations, floating point comparison is tricky business.
double a = 1.0;
double b = 1.0;
double c = a - b;if(c == 0)
printf("you'd expect to see this");
else
printf("but you might see this, because c is really 0.00000000000000000000000000001 or something.");
I appreciate the principle you are trying to state, but I must point out that floating point represents many integers exactly. For example, a 64-bit double can (easily) represent every 32-bit integer precisely. So in the above example, c will always be exactly zero. Period.
Where you might get into trouble is summing non integers (ie. the floating point part), or too-large integers. For example, in Python:
>>> 0.3 + 0.3 + 0.3 == .9
False
>>> 3 * 0.3 == .9
False