summaryrefslogtreecommitdiffstatshomepage
path: root/py/objfloat.c
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-04-18 21:12:52 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-04-18 21:21:59 +0300
commit7de5377ca7eeb7828031f83be417cda3a188069b (patch)
treed4a9583637c1e4edcfa13c1d7865ab8e204c2b13 /py/objfloat.c
parent599bbc111cbd83329e9418cefd1ed62ca2ed984c (diff)
downloadmicropython-7de5377ca7eeb7828031f83be417cda3a188069b.tar.gz
micropython-7de5377ca7eeb7828031f83be417cda3a188069b.zip
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.
Diffstat (limited to 'py/objfloat.c')
-rw-r--r--py/objfloat.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/py/objfloat.c b/py/objfloat.c
index 804101978e..9249160579 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