hmmm how about FLT_EPSILON and DBL_EPSILON?Originally Posted by robatino
something like this, made quickly
Code:int compareEqual(float a, float b) { if (abs(a-b) <= (max(abs(a), abs(b)) * FLT_EPSILON) { return 1; } else { return 0; } }
This is a discussion on How can I test if something is an integer or not? within the C Programming forums, part of the General Programming Boards category; Originally Posted by robatino I used the dreaded "==". It works for inputs up to about 15 or 16 decimal ...
hmmm how about FLT_EPSILON and DBL_EPSILON?Originally Posted by robatino
something like this, made quickly
Code:int compareEqual(float a, float b) { if (abs(a-b) <= (max(abs(a), abs(b)) * FLT_EPSILON) { return 1; } else { return 0; } }