mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-24 15:25:00 +08:00
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.
This commit is contained in:
commit
590aaff330
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user