diff Objects/floatobject.c @ 44268:7ae604b3533b

Merged revisions 59450-59464 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r59455 | guido.van.rossum | 2007-12-10 21:42:53 +0100 (Mon, 10 Dec 2007) | 2 lines Remove a 2.2-ism. ........ r59459 | christian.heimes | 2007-12-10 23:28:56 +0100 (Mon, 10 Dec 2007) | 4 lines Backport of r59456:59458 from py3k to trunk Issue #1580: New free format floating point representation based on "Floating-Point Printer Sample Code", by Robert G. Burger. For example repr(11./5) now returns '2.2' instead of '2.2000000000000002'. Thanks to noam for the patch! I had to modify doubledigits.c slightly to support X64 and IA64 machines on Windows. I also added the new file to the three project files. ........ r59460 | guido.van.rossum | 2007-12-11 00:00:12 +0100 (Tue, 11 Dec 2007) | 4 lines Patch #1643738 by Ulisses Furquim -- make the is_tripped variable in signalmodule.c more robust. Includes Martin von Loewis's suggestion to set is_tripped after .tripped. ........ r59463 | kurt.kaiser | 2007-12-11 01:04:57 +0100 (Tue, 11 Dec 2007) | 2 lines format_paragraph_event wasn't returning 'break' ........ r59464 | christian.heimes | 2007-12-11 01:54:34 +0100 (Tue, 11 Dec 2007) | 3 lines The new float repr causes too much trouble and pain. I'm disabling the feature until we have sorted out the issues on all machines. 64bit machines seem to have issues and Guido has reported even worse. Guido: It's pretty bad actually -- repr(1e5) comes out as '1.0'... Ditto for repr(1eN) for most N... Both in 2.6 and in 3.0... ........
author Christian Heimes <christian@cheimes.de>
date Tue, 11 Dec 2007 01:06:40 +0000
parents 682d9788a038
children 4dc01402d78a
line wrap: on
line diff
--- a/Objects/floatobject.c	Mon Dec 10 23:58:35 2007 +0000
+++ b/Objects/floatobject.c	Tue Dec 11 01:06:40 2007 +0000
@@ -281,6 +281,7 @@
 	format_double(buf, buflen, PyFloat_AS_DOUBLE(v), precision);
 }
 
+#ifdef Py_BROKEN_REPR
 /* The following function is based on Tcl_PrintDouble,
  * from tclUtil.c.
  */
@@ -382,6 +383,8 @@
 	format_double_repr(buf, PyFloat_AS_DOUBLE(v));
 }
 
+#endif /* Py_BROKEN_REPR */
+
 /* Macro and helper that convert PyObject obj to a C double and store
    the value in dbl.  If conversion to double raises an exception, obj is
    set to NULL, and the function invoking this macro returns NULL.  If
@@ -434,8 +437,14 @@
 static PyObject *
 float_repr(PyFloatObject *v)
 {
+#ifdef Py_BROKEN_REPR
 	char buf[30];
 	format_float_repr(buf, v);
+#else
+	char buf[100];
+	format_float(buf, sizeof(buf), v, PREC_REPR);
+#endif
+
 	return PyUnicode_FromString(buf);
 }
 
@@ -1327,9 +1336,11 @@
 
 	double_format = detected_double_format;
 	float_format = detected_float_format;
-	
+
+#ifdef Py_BROKEN_REPR	
 	/* Initialize floating point repr */
 	_PyFloat_DigitsInit();
+#endif
 }
 
 void