On 5/14/2018 7:02 PM, Vincent Povirk wrote:
+static BOOL compare_float(float f, float g, unsigned int ulps) +{
- int x = *(int *)&f;
- int y = *(int *)&g;
- if (x < 0)
x = INT_MIN - x;
- if (y < 0)
y = INT_MIN - y;
- if (abs(x - y) > ulps)
return FALSE;
- return TRUE;
+}
I'm confused by this function. Why are you testing the difference of 2 floats interpreted as integers?
That's a way to compare them, without introducing arbitrary difference constant, that is meaningless out of context of numbers being compared.
The goal of the test is to test that numbers are close enough, in terms of a number of representable floating point values between comparands.
The function was taken as is from existing d3d tests.