[Python-checkins] cpython (2.7): Issue #9742: Sneaky fix for build failure on Solaris 9.

mark.dickinson python-checkins at python.org
Sat Nov 17 21:19:01 CET 2012


http://hg.python.org/cpython/rev/ff300ccd119d
changeset: 80479:ff300ccd119d
branch: 2.7
user: Mark Dickinson <mdickinson at enthought.com>
date: Sat Nov 17 20:18:52 2012 +0000
summary:
 Issue #9742: Sneaky fix for build failure on Solaris 9.
files:
 Objects/floatobject.c | 9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -1088,6 +1088,15 @@
 PyObject *result = NULL;
 _Py_SET_53BIT_PRECISION_HEADER;
 
+ /* Easy path for the common case ndigits == 0. */
+ if (ndigits == 0) {
+ rounded = round(x);
+ if (fabs(rounded - x) == 0.5)
+ /* halfway between two integers; use round-away-from-zero */
+ rounded = x + (x > 0.0 ? 0.5 : -0.5);
+ return PyFloat_FromDouble(rounded);
+ }
+
 /* The basic idea is very simple: convert and round the double to a
 decimal string using _Py_dg_dtoa, then convert that decimal string
 back to a double with _Py_dg_strtod. There's one minor difficulty:
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /