diff Include/floatobject.h @ 53787:c6376d3fa968

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.
author Eric Smith <eric@trueblade.com>
date Tue, 05 May 2009 14:04:18 +0000
parents de0bf60f1245
children eafe07d40eb7
line wrap: on
line diff
--- a/Include/floatobject.h	Tue May 05 13:07:30 2009 +0000
+++ b/Include/floatobject.h	Tue May 05 14:04:18 2009 +0000
@@ -21,6 +21,12 @@
 #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