summaryrefslogtreecommitdiffstats
path: root/src/H5Zscaleoffset.c
diff options
context:
space:
mode:
authorMuQun Yang <ymuqun@hdfgroup.org>2005-05-09 23:30:56 (GMT)
committerMuQun Yang <ymuqun@hdfgroup.org>2005-05-09 23:30:56 (GMT)
commitb6f01bff10d38867d7e00ffa3ec1297d13b7b499 (patch)
tree24c2af35c6fe040cc657c0fb6da820c51c4305cb /src/H5Zscaleoffset.c
parent3d4049134eb8daf317dc9344eb323b94fadd13f6 (diff)
downloadhdf5-b6f01bff10d38867d7e00ffa3ec1297d13b7b499.zip
hdf5-b6f01bff10d38867d7e00ffa3ec1297d13b7b499.tar.gz
hdf5-b6f01bff10d38867d7e00ffa3ec1297d13b7b499.tar.bz2
[svn-r10741] Purpose:
Minor change for rounding of floating-point value for scaleoffset filter. Description: Always round to the bigger absolute integer value if floating-point data is in the middle. 0.5->1, -0.5->-1. Solution: Platforms tested: Too minor to test Misc. update:
Diffstat (limited to 'src/H5Zscaleoffset.c')
-rw-r--r--src/H5Zscaleoffset.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c
index cfbe59c..4f668a6 100644
--- a/src/H5Zscaleoffset.c
+++ b/src/H5Zscaleoffset.c
@@ -1190,6 +1190,9 @@ static void H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, unsigned dtype
}
/* Round a floating-point value to the nearest integer value 4/19/05 */
+/* rounding to the bigger absolute value if val is in the middle,
+ 0.5 -> 1, -0.5 ->-1
+5/9/05, KY */
static double H5Z_scaleoffset_rnd(double val)
{
double u_val, l_val;
@@ -1198,11 +1201,11 @@ static double H5Z_scaleoffset_rnd(double val)
l_val = HDfloor(val);
if(val > 0) {
- if((u_val - val)<(val - l_val)) return u_val;
+ if((u_val - val)<=(val - l_val)) return u_val;
else return l_val;
}
else {
- if((val - l_val)<(u_val - val)) return l_val;
+ if((val - l_val)<=(u_val - val)) return l_val;
else return u_val;
}
}