summaryrefslogtreecommitdiffstats
path: root/src/H5Zscaleoffset.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2016-09-14 21:02:43 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2016-09-14 21:02:43 (GMT)
commit7f817fea7c50cea4305bc14fcaf4d80fb3dc42e4 (patch)
treee18b6cefc2cc51c58ebacec1d6a9051742754f71 /src/H5Zscaleoffset.c
parentc1c384878ba58193120c3da804d761542c47bd7d (diff)
parent052efd9bde06ea2427beffd3ea493cbc53a17608 (diff)
downloadhdf5-7f817fea7c50cea4305bc14fcaf4d80fb3dc42e4.zip
hdf5-7f817fea7c50cea4305bc14fcaf4d80fb3dc42e4.tar.gz
hdf5-7f817fea7c50cea4305bc14fcaf4d80fb3dc42e4.tar.bz2
Merge branch 'develop' into evict_on_close
Diffstat (limited to 'src/H5Zscaleoffset.c')
-rw-r--r--src/H5Zscaleoffset.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c
index 1cca9b1..91a6c00 100644
--- a/src/H5Zscaleoffset.c
+++ b/src/H5Zscaleoffset.c
@@ -667,6 +667,58 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{
H5Z_scaleoffset_modify_4(i, type, pow_fun, buf, d_nelmts, min, D_val) \
}
+/* Include our own rounding routine and alias it to the stdc macros, if they
+ * aren't available.
+ */
+#if !(defined(H5_HAVE_LLROUND) && defined(H5_HAVE_LLROUNDF) && defined(H5_HAVE_LROUND) && defined(H5_HAVE_LROUNDF) && defined(H5_HAVE_ROUND) && defined(H5_HAVE_ROUNDF))
+/* 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;
+
+ u_val = HDceil(val);
+ l_val = HDfloor(val);
+
+ if(val > 0) {
+ if((u_val - val) <= (val - l_val))
+ return u_val;
+ else
+ return l_val;
+ } /* end if */
+ else {
+ if((val - l_val) <= (u_val - val))
+ return l_val;
+ else
+ return u_val;
+ }
+} /* H5Z__scaleoffset_rnd() */
+
+/* Alias rounding macros to routine above, if not defined */
+#if !defined(H5_HAVE_LLROUND)
+#define llround(x) H5Z__scaleoffset_rnd(x)
+#endif /* !defined(H5_HAVE_LLROUND) */
+#if !defined(H5_HAVE_LLROUNDF)
+#define llroundf(x) H5Z__scaleoffset_rnd(x)
+#endif /* !defined(H5_HAVE_LLROUNDF) */
+#if !defined(H5_HAVE_LROUND)
+#define lround(x) H5Z__scaleoffset_rnd(x)
+#endif /* !defined(H5_HAVE_LROUND) */
+#if !defined(H5_HAVE_LROUNDF)
+#define lroundf(x) H5Z__scaleoffset_rnd(x)
+#endif /* !defined(H5_HAVE_LROUNDF) */
+#if !defined(H5_HAVE_ROUND)
+#define round(x) H5Z__scaleoffset_rnd(x)
+#endif /* !defined(H5_HAVE_ROUND) */
+#if !defined(H5_HAVE_ROUNDF)
+#define roundf(x) H5Z__scaleoffset_rnd(x)
+#endif /* !defined(H5_HAVE_ROUNDF) */
+
+#endif /* !(defined(H5_HAVE_LLROUND) && defined(H5_HAVE_LLROUNDF) && defined(H5_HAVE_LROUND) && defined(H5_HAVE_LROUNDF) && defined(H5_HAVE_ROUND) && defined(H5_HAVE_ROUNDF)) */
+
/*-------------------------------------------------------------------------
* Function: H5Z_can_apply_scaleoffset