Commit 73986d82 authored by Doug Nazar's avatar Doug Nazar

orctest: Switch nearby float comparison to ULP method

parent 84954727
Pipeline #54228 passed with stage
in 1 minute and 55 seconds
......@@ -211,9 +211,6 @@ orc_array_set_pattern_2 (OrcArray *array, OrcRandomContext *context,
}
}
#define MIN_NONDENORMAL (1.1754944909521339405e-38)
#define MIN_NONDENORMAL_D (2.2250738585072014e-308)
int
orc_array_compare (OrcArray *array1, OrcArray *array2, int flags)
{
......@@ -230,7 +227,7 @@ orc_array_compare (OrcArray *array1, OrcArray *array2, int flags)
for (i=0;i<array1->n;i++){
if (isnan(a[i]) && isnan(b[i])) continue;
if (a[i] == b[i]) continue;
if (fabs(a[i] - b[i]) < MIN_NONDENORMAL) continue;
if ((a[i] < 0.0) == (b[i] < 0.0) && abs(*(orc_uint32 *)&a[i] - *(orc_uint32 *)&b[i]) <= 2) continue;
return FALSE;
}
}
......@@ -247,7 +244,7 @@ orc_array_compare (OrcArray *array1, OrcArray *array2, int flags)
for (i=0;i<array1->n;i++){
if (isnan(a[i]) && isnan(b[i])) continue;
if (a[i] == b[i]) continue;
if (fabs(a[i] - b[i]) < MIN_NONDENORMAL_D) continue;
if ((a[i] < 0.0) == (b[i] < 0.0) && abs(*(orc_uint64 *)&a[i] - *(orc_uint64 *)&b[i]) <= 2) continue;
return FALSE;
}
}
......
......@@ -44,8 +44,6 @@
#define snprintf _snprintf
#endif
#define MIN_NONDENORMAL (1.1754944909521339405e-38)
void _orc_profile_init(void);
OrcRandomContext rand_context;
......@@ -527,10 +525,12 @@ float_compare (OrcArray *array1, OrcArray *array2, int i, int j)
case 4:
if (isnan(*(float *)ptr1) && isnan(*(float *)ptr2)) return TRUE;
if (*(float *)ptr1 == *(float *)ptr2) return TRUE;
if (fabs(*(float *)ptr1 - *(float *)ptr2) < MIN_NONDENORMAL) return TRUE;
if ((*(float *)ptr1 < 0.0) == (*(float *)ptr2 < 0.0) && abs(*(orc_uint32 *)ptr1 - *(orc_uint32 *)ptr2) <= 2) return TRUE;
return FALSE;
case 8:
/* FIXME */
if (isnan(*(double *)ptr1) && isnan(*(double *)ptr2)) return TRUE;
if (*(double *)ptr1 == *(double *)ptr2) return TRUE;
if ((*(double *)ptr1 < 0.0) == (*(double *)ptr2 < 0.0) && abs(*(orc_uint64 *)ptr1 - *(orc_uint64 *)ptr2) <= 2) return TRUE;
return FALSE;
}
return FALSE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment