summaryrefslogtreecommitdiff
path: root/Python/pymath.c
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-04-18 13:58:18 +0000
committerMark Dickinson <dickinsm@gmail.com>2009-04-18 13:58:18 +0000
commit408e5fc144d187ed34e672280a017dcf2647ae3c (patch)
tree4839f6bed76aaf48e12b98233d423ab64cf46d91 /Python/pymath.c
parent5920b1c0dc0a8e9c4bfc3c1cca24be1003de688d (diff)
downloadcpython-408e5fc144d187ed34e672280a017dcf2647ae3c.tar.gz
Add check for C99 round function to configure, and define
a fallback function if round doesn't exist.
Diffstat (limited to 'Python/pymath.c')
-rw-r--r--Python/pymath.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/Python/pymath.c b/Python/pymath.c
index 2e049be870..eb06eb2244 100644
--- a/Python/pymath.c
+++ b/Python/pymath.c
@@ -69,6 +69,19 @@ copysign(double x, double y)
}
#endif /* HAVE_COPYSIGN */
+#ifndef HAVE_ROUND
+double
+round(double x)
+{
+ double absx, y;
+ absx = fabs(x);
+ y = floor(absx);
+ if (absx - y >= 0.5)
+ y += 1.0;
+ return copysign(y, x);
+}
+#endif /* HAVE_ROUND */
+
#ifndef HAVE_LOG1P
#include <float.h>