Commit 8c7c61d2 authored by Doug Nazar's avatar Doug Nazar

orctest: Fix ULP compare and make compatible with clang

parent 63f6cfac
......@@ -227,7 +227,9 @@ 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 ((a[i] < 0.0) == (b[i] < 0.0) && (*(orc_uint32 *)&a[i] - *(orc_uint32 *)&b[i]) <= 2) continue;
if ((a[i] < 0.0) == (b[i] < 0.0) &&
abs((orc_int32)(*(orc_uint32 *)&a[i] - *(orc_uint32 *)&b[i])) <= 2)
continue;
return FALSE;
}
}
......@@ -244,7 +246,9 @@ 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 ((a[i] < 0.0) == (b[i] < 0.0) && (*(orc_uint64 *)&a[i] - *(orc_uint64 *)&b[i]) <= 2) continue;
if ((a[i] < 0.0) == (b[i] < 0.0) &&
llabs((orc_int64)(*(orc_uint64 *)&a[i] - *(orc_uint64 *)&b[i])) <= 2)
continue;
return FALSE;
}
}
......
......@@ -522,12 +522,16 @@ 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 ((*(float *)ptr1 < 0.0) == (*(float *)ptr2 < 0.0) && (*(orc_uint32 *)ptr1 - *(orc_uint32 *)ptr2) <= 2) return TRUE;
if ((*(float *)ptr1 < 0.0) == (*(float *)ptr2 < 0.0) &&
abs((orc_int32)(*(orc_uint32 *)ptr1 - *(orc_uint32 *)ptr2) <= 2))
return TRUE;
return FALSE;
case 8:
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) && (*(orc_uint64 *)ptr1 - *(orc_uint64 *)ptr2) <= 2) return TRUE;
if ((*(double *)ptr1 < 0.0) == (*(double *)ptr2 < 0.0) &&
llabs((orc_int64)(*(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