summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2020-01-24 13:34:43 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2020-01-24 13:34:43 (GMT)
commit590aaff33046df99a4d88ba59e4b461e060b36e4 (patch)
treebb85224bcdcb2826bfe98b7b80b756613b65788a
parent3e22f567c4359c464507bf34f3dc97eb00296143 (diff)
parent9475ee5d59e9ac916271a64c5372dfc28f709417 (diff)
downloadhdf5-590aaff33046df99a4d88ba59e4b461e060b36e4.zip
hdf5-590aaff33046df99a4d88ba59e4b461e060b36e4.tar.gz
hdf5-590aaff33046df99a4d88ba59e4b461e060b36e4.tar.bz2
Merge pull request #2303 in HDFFV/hdf5 from ~DEROBINS/hdf5_der:develop_minor to develop
* commit '9475ee5d59e9ac916271a64c5372dfc28f709417': Optimized the floating point comparisons a little bit. Fix for failing h5diff tests involving floating-point compares.
-rw-r--r--tools/lib/h5diff_array.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 6cfe3d2..3127870 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -4559,12 +4559,16 @@ static hbool_t equal_double(double value, double expected, diff_opt_t *opts) {
return FALSE;
}
- if (H5_DBL_ABS_EQUAL(value, expected))
- return TRUE;
-
- if (opts->use_system_epsilon)
- if (ABS((value-expected)) < DBL_EPSILON)
+ if (opts->use_system_epsilon) {
+ /* Check equality within some epsilon */
+ if (H5_DBL_ABS_EQUAL(value, expected))
+ return TRUE;
+ }
+ else {
+ /* Check bits */
+ if (!HDmemcmp(&value, &expected, sizeof(double)))
return TRUE;
+ }
return FALSE;
}
@@ -4603,12 +4607,16 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *opts)
return FALSE;
}
- if (H5_LDBL_ABS_EQUAL(value, expected))
- return TRUE;
-
- if (opts->use_system_epsilon)
- if (ABS((value-expected)) < DBL_EPSILON)
+ if (opts->use_system_epsilon) {
+ /* Check equality within some epsilon */
+ if (H5_LDBL_ABS_EQUAL(value, expected))
return TRUE;
+ }
+ else {
+ /* Check bits */
+ if (!HDmemcmp(&value, &expected, sizeof(long double)))
+ return TRUE;
+ }
return FALSE;
}
@@ -4645,12 +4653,16 @@ static hbool_t equal_float(float value, float expected, diff_opt_t *opts) {
return FALSE;
}
- if (H5_FLT_ABS_EQUAL(value, expected))
- return TRUE;
-
- if (opts->use_system_epsilon)
- if (ABS( (value-expected) ) < FLT_EPSILON)
+ if (opts->use_system_epsilon) {
+ /* Check equality within some epsilon */
+ if (H5_FLT_ABS_EQUAL(value, expected))
return TRUE;
+ }
+ else {
+ /* Check bits */
+ if (!HDmemcmp(&value, &expected, sizeof(float)))
+ return TRUE;
+ }
return FALSE;
}