[Python-checkins] r71642 - python/branches/py3k-short-float-repr/Python/pystrtod.c

eric.smith python-checkins at python.org
Thu Apr 16 12:46:23 CEST 2009


Author: eric.smith
Date: Thu Apr 16 12:46:23 2009
New Revision: 71642

Log:
When using Py_DTSF_ADD_DOT_O, Don't add '.0' if we have an exponent. The output already looks like a float, no reason to modify it further.

Modified:
   python/branches/py3k-short-float-repr/Python/pystrtod.c

Modified: python/branches/py3k-short-float-repr/Python/pystrtod.c
==============================================================================
--- python/branches/py3k-short-float-repr/Python/pystrtod.c	(original)
+++ python/branches/py3k-short-float-repr/Python/pystrtod.c	Thu Apr 16 12:46:23 2009
@@ -333,8 +333,9 @@
 	}
 }
 
-/* Ensure that buffer has a decimal point in it.  The decimal point
-   will not be in the current locale, it will always be '.' */
+/* Ensure that buffer has a decimal point in it.  The decimal point will not
+   be in the current locale, it will always be '.'. Don't add a decimal if an
+   exponent is present. */
 Py_LOCAL_INLINE(void)
 ensure_decimal_point(char* buffer, size_t buf_size)
 {
@@ -363,7 +364,8 @@
 			insert_count = 1;
 		}
 	}
-	else {
+	else if (!(*p == 'e' || *p == 'E')) {
+		/* Don't add ".0" if we have an exponent. */
 		chars_to_insert = ".0";
 		insert_count = 2;
 	}


More information about the Python-checkins mailing list