As you can see, even though dbl2 and dbl3 are equal, the last statement dbl2 != dbl3 contradicts. Further investigation, I printed out their hex values as follows:
1 2
printf("hex of dbl2 %x\n", dbl2);
printf("hex of dbl3 %x\n", dbl3);
Result:
/***************************
printf("hex of dbl2 %x\n", 9999999a);
printf("hex of dbl3 %x\n", 8c737e42);
/***************************
even though the numbers are the same why is dbl2 != dbl3. A conceptual explanation would really help here.
I'm not sure if any of the articles touch on the reasons for it, but they are esoteric. Basically it is a mismatch of precision due to conversion between one value and another on the FPU's stack.
Perhaps round to whatever you think is significant. Then your =='s might be the way you mean them. I'm new to this whole thing and I find it a bit interesting.
What Zaita has done is check to see whether the difference between the two values are within an acceptable distance from true zero. This allows for any accuracy errors.
Yep :)
But macro's should be well defined in your documentation in commercial projects to ensure they are not used incorrectly. This macro is known to the other developers as a simple double/float check. They know it's context and when to not use it. It's also defined in our documentation :)