]> granicus.if.org Git - python/commitdiff
Issue #532631: Replace confusing fabs(x)/1e25 >= 1e25 test
authorMark Dickinson <dickinsm@gmail.com>
Sun, 29 Mar 2009 14:37:51 +0000 (14:37 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Sun, 29 Mar 2009 14:37:51 +0000 (14:37 +0000)
with fabs(x) >= 1e50, and fix documentation.

Doc/library/stdtypes.rst
Objects/stringlib/formatter.h
Objects/stringobject.c
Objects/unicodeobject.c

index f3ff505b0bff3821f8c374c0285ad18b13114cb7..2e540394ea0f191da67898fee42b2a0d98d26d85 100644 (file)
@@ -1409,7 +1409,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::
index 2e3e5a675854f923f2d8fbaa983db15e16ee68b7..86235a64b508ab292bb741b3f855fde0ea3faef1 100644 (file)
@@ -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
index 8f82f4f48e86eda44ca58e789811dd8825305703..3b5d331bed5cd2f1129d6a92fbedb342041d0f60 100644 (file)
@@ -4344,7 +4344,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:
 
index 107ed295656e83cf13c4027178ea4c60f9a559c0..4ce9bed1894a58725b70fd1e29b0d542a0826031 100644 (file)
@@ -8286,7 +8286,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: