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.
This commit is contained in:
Paul Sokolovsky 2014-04-18 21:12:52 +03:00
parent 599bbc111c
commit 7de5377ca7
1 changed files with 1 additions and 1 deletions

View File

@ -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