14 May
2018
14 May
'18
4:02 p.m.
+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?