diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-04-18 13:58:18 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-04-18 13:58:18 (GMT) |
commit | f253786a807967c2a7f289fa294b66d5dffadcdd (patch) | |
tree | b5583470a84088050578da953c1ff16946b9ad5e /Python | |
parent | f498113f3f8585f5e7c5f4cedca0108c41628c75 (diff) | |
download | cpython-f253786a807967c2a7f289fa294b66d5dffadcdd.zip cpython-f253786a807967c2a7f289fa294b66d5dffadcdd.tar.gz cpython-f253786a807967c2a7f289fa294b66d5dffadcdd.tar.bz2 |
Add check for C99 round function to configure, and define
a fallback function if round doesn't exist.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/pymath.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Python/pymath.c b/Python/pymath.c index 2e049be..eb06eb2 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> |