diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2020-01-24 02:58:08 (GMT) |
---|---|---|
committer | David Young <dyoung@hdfgroup.org> | 2020-05-20 14:31:53 (GMT) |
commit | 23f103cf6b0e0c13c1ca4f3ff38cc19447ce6891 (patch) | |
tree | 70c99c5585aed0afb3a4ed101af13513024a4236 /tools/lib | |
parent | 0479a345ccb884e4bbe98d6fa9af051790a81dd0 (diff) | |
download | hdf5-23f103cf6b0e0c13c1ca4f3ff38cc19447ce6891.zip hdf5-23f103cf6b0e0c13c1ca4f3ff38cc19447ce6891.tar.gz hdf5-23f103cf6b0e0c13c1ca4f3ff38cc19447ce6891.tar.bz2 |
Fix for failing h5diff tests involving floating-point compares.
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/h5diff_array.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 6cfe3d2..f6dff64 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -4559,11 +4559,15 @@ static hbool_t equal_double(double value, double expected, diff_opt_t *opts) { return FALSE; } - if (H5_DBL_ABS_EQUAL(value, expected)) + /* Are the bits the same? */ + if (!HDmemcmp(&value, &expected, sizeof(double))) return TRUE; + /* Check for equality within appropriate floating-point + * tolerance, if requested. + */ if (opts->use_system_epsilon) - if (ABS((value-expected)) < DBL_EPSILON) + if (H5_DBL_ABS_EQUAL(value, expected)) return TRUE; return FALSE; @@ -4603,11 +4607,15 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *opts) return FALSE; } - if (H5_LDBL_ABS_EQUAL(value, expected)) + /* Are the bits the same? */ + if (!HDmemcmp(&value, &expected, sizeof(long double))) return TRUE; + /* Check for equality within appropriate floating-point + * tolerance, if requested. + */ if (opts->use_system_epsilon) - if (ABS((value-expected)) < DBL_EPSILON) + if (H5_LDBL_ABS_EQUAL(value, expected)) return TRUE; return FALSE; @@ -4645,11 +4653,15 @@ static hbool_t equal_float(float value, float expected, diff_opt_t *opts) { return FALSE; } - if (H5_FLT_ABS_EQUAL(value, expected)) + /* Are the bits the same? */ + if (!HDmemcmp(&value, &expected, sizeof(float))) return TRUE; + /* Check for equality within appropriate floating-point + * tolerance, if requested. + */ if (opts->use_system_epsilon) - if (ABS( (value-expected) ) < FLT_EPSILON) + if (H5_FLT_ABS_EQUAL(value, expected)) return TRUE; return FALSE; |