From: Mark Dickinson Date: Sun, 29 Mar 2009 15:06:29 +0000 (+0000) Subject: Merged revisions 70678 via svnmerge from X-Git-Tag: v2.6.2c1~76 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a30f349ecf57d7280bf179d6446f8fe5a3dede4f;p=thirdparty%2FPython%2Fcpython.git Merged revisions 70678 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r70678 | mark.dickinson | 2009-03-29 15:37:51 +0100 (Sun, 29 Mar 2009) | 3 lines Issue #532631: Replace confusing fabs(x)/1e25 >= 1e25 test with fabs(x) >= 1e50, and fix documentation. ........ --- diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index b4b8ef9e4d19..d07b10fbb825 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1378,7 +1378,7 @@ that ``'\0'`` is the end of the string. .. XXX Examples? For safety reasons, floating point precisions are clipped to 50; ``%f`` -conversions for numbers whose absolute value is over 1e25 are replaced by ``%g`` +conversions for numbers whose absolute value is over 1e50 are replaced by ``%g`` conversions. [#]_ All other errors raise exceptions. .. index:: diff --git a/Objects/stringlib/formatter.h b/Objects/stringlib/formatter.h index 2e3e5a675854..86235a64b508 100644 --- a/Objects/stringlib/formatter.h +++ b/Objects/stringlib/formatter.h @@ -789,7 +789,7 @@ format_float_internal(PyObject *value, if (precision < 0) precision = 6; - if (type == 'f' && (fabs(x) / 1e25) >= 1e25) + if (type == 'f' && fabs(x) >= 1e50) type = 'g'; /* cast "type", because if we're in unicode we need to pass a diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 7f30f6663db2..84e107b6a967 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -4336,7 +4336,7 @@ formatfloat(char *buf, size_t buflen, int flags, } if (prec < 0) prec = 6; - if (type == 'f' && fabs(x)/1e25 >= 1e25) + if (type == 'f' && fabs(x) >= 1e50) type = 'g'; /* Worst case length calc to ensure no buffer overrun: diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 72bfb8373a7d..70c95a15ca29 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -8228,7 +8228,7 @@ formatfloat(Py_UNICODE *buf, return -1; if (prec < 0) prec = 6; - if (type == 'f' && (fabs(x) / 1e25) >= 1e25) + if (type == 'f' && fabs(x) >= 1e50) type = 'g'; /* Worst case length calc to ensure no buffer overrun: