Commit 864038da authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

objfloat: Make sure that floats always have dot (for C "double" type case).

This matches CPython behavior and hopefully can be treated as general
Python semantics.
parent a8e60c1f
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <math.h>
......@@ -23,7 +25,13 @@ STATIC void float_print(void (*print)(void *env, const char *fmt, ...), void *en
format_float(o->value, buf, sizeof(buf), 'g', 6, '\0');
print(env, "%s", buf);
print(env, "%.8g", (double) o->value);
char buf[32];
sprintf(buf, "%.8g", (double) o->value);
print(env, buf);
if (strchr(buf, '.') == NULL) {
// Python floats always have decimal point
print(env, ".0");
Markdown is supported
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