From 7de5377ca7eeb7828031f83be417cda3a188069b Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 18 Apr 2014 21:12:52 +0300 Subject: objfloat: Try to achieve the same float printing format as CPython does. Test usecase I used is print(time.time()) and print(time.time() - time.time()). On Linux/Glibc they now give the same output as CPython 3.3. Specifically, time.time() gives non-exponential output with 7 decimal digits, and subtraction gives exponential output e-06/e-07. --- py/objfloat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'py/objfloat.c') diff --git a/py/objfloat.c b/py/objfloat.c index 804101978..924916057 100644 --- a/py/objfloat.c +++ b/py/objfloat.c @@ -30,7 +30,7 @@ STATIC void float_print(void (*print)(void *env, const char *fmt, ...), void *en } #else char buf[32]; - sprintf(buf, "%.8g", (double) o->value); + sprintf(buf, "%.17g", (double) o->value); print(env, buf); if (strchr(buf, '.') == NULL) { // Python floats always have decimal point -- cgit v1.2.3