From b6f01bff10d38867d7e00ffa3ec1297d13b7b499 Mon Sep 17 00:00:00 2001 From: MuQun Yang Date: Mon, 9 May 2005 18:30:56 -0500 Subject: [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: --- src/H5Zscaleoffset.c | 7 +++++-- 1 file 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; } } -- cgit v0.12