mirror of
https://github.com/janet-lang/janet
synced 2024-11-25 09:47:17 +00:00
Print proper integers as integers.
This commit is contained in:
parent
8e31bda8f6
commit
36ef1c4749
@ -37,7 +37,8 @@
|
|||||||
|
|
||||||
static void number_to_string_b(JanetBuffer *buffer, double x) {
|
static void number_to_string_b(JanetBuffer *buffer, double x) {
|
||||||
janet_buffer_ensure(buffer, buffer->count + BUFSIZE, 2);
|
janet_buffer_ensure(buffer, buffer->count + BUFSIZE, 2);
|
||||||
int count = snprintf((char *) buffer->data + buffer->count, BUFSIZE, "%g", x);
|
const char *fmt = (x == floor(x) && x <= 2.0e53 && x >= -2.0e53) ? "%.0f" : "%g";
|
||||||
|
int count = snprintf((char *) buffer->data + buffer->count, BUFSIZE, fmt, x);
|
||||||
buffer->count += count;
|
buffer->count += count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user