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.
This commit is contained in:
parent
a8e60c1fde
commit
864038dab7
|
@ -1,4 +1,6 @@
|
|||
#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);
|
||||
#else
|
||||
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");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue