Commit 7de5377c authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

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.
parent 599bbc11
......@@ -30,7 +30,7 @@ STATIC void float_print(void (*print)(void *env, const char *fmt, ...), void *en
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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment