Mercurial > cpython-lru_cache-weakref
diff Python/pymath.c @ 53227:96d82facd890 legacy-trunk
Backport r71704 (add configure check for C99 round function) to trunk.
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Sat, 18 Apr 2009 14:41:37 +0000 |
| parents | ad5c7eaccea1 |
| children | 2ab08c919648 |
line wrap: on
line diff
--- a/Python/pymath.c Sat Apr 18 14:13:43 2009 +0000 +++ b/Python/pymath.c Sat Apr 18 14:41:37 2009 +0000 @@ -47,6 +47,19 @@ } #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>
