diff options
author | Doug Nazar <nazard@nazar.ca> | 2019-08-31 18:08:58 +0300 |
---|---|---|
committer | Doug Nazar <nazard@nazar.ca> | 2019-08-31 18:08:58 +0300 |
commit | 8c7c61d2014a9190fec4c6c97f8a759916ca9fc7 (patch) | |
tree | c6dd652983f94086afdfc154f3affb0c2a59ddd0 /orc-test/orctest.c | |
parent | 63f6cfac0fa9dd3263540eb0d78fc6a20af9016c (diff) |
orctest: Fix ULP compare and make compatible with clang
Diffstat (limited to 'orc-test/orctest.c')
-rw-r--r-- | orc-test/orctest.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/orc-test/orctest.c b/orc-test/orctest.c index 4b07823..614421b 100644 --- a/orc-test/orctest.c +++ b/orc-test/orctest.c @@ -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; |