summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorEric Smith <eric@trueblade.com>2009-05-05 18:26:08 (GMT)
committerEric Smith <eric@trueblade.com>2009-05-05 18:26:08 (GMT)
commita985a3aee46dfda4b59cf20414bab199ba1b9659 (patch)
treed7c3615c46cb9a17b3c330ab78c41dd6023adf2f /Include
parent929ab934891719ea1561a623ee1b2e502b59e022 (diff)
downloadcpython-a985a3aee46dfda4b59cf20414bab199ba1b9659.zip
cpython-a985a3aee46dfda4b59cf20414bab199ba1b9659.tar.gz
cpython-a985a3aee46dfda4b59cf20414bab199ba1b9659.tar.bz2
Issue #5920: Changed format.__float__ and complex.__float__ to use a precision of 12 when using the empty presentation type. This more closely matches str()'s behavior and reduces surprises when adding alignment flags to an empty format string. Patch by Mark Dickinson.
Diffstat (limited to 'Include')
-rw-r--r--Include/floatobject.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/Include/floatobject.h b/Include/floatobject.h
index 60ede40..6c11036 100644
--- a/Include/floatobject.h
+++ b/Include/floatobject.h
@@ -21,6 +21,12 @@ PyAPI_DATA(PyTypeObject) PyFloat_Type;
#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type)
#define PyFloat_CheckExact(op) (Py_TYPE(op) == &PyFloat_Type)
+/* The str() precision PyFloat_STR_PRECISION is chosen so that in most cases,
+ the rounding noise created by various operations is suppressed, while
+ giving plenty of precision for practical use. */
+
+#define PyFloat_STR_PRECISION 12
+
#ifdef Py_NAN
#define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN)
#endif