aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/integers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdlib/integers.c')
-rw-r--r--src/stdlib/integers.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/stdlib/integers.c b/src/stdlib/integers.c
index 7250e2a2..7c623663 100644
--- a/src/stdlib/integers.c
+++ b/src/stdlib/integers.c
@@ -28,9 +28,13 @@ public int Int$print(FILE *f, Int_t i) {
static inline Text_t _int64_to_text(int64_t n)
{
+ if (n == INT64_MIN)
+ return Text("-9223372036854775808");
+
char buf[21] = {[20]=0}; // Big enough for INT64_MIN + '\0'
char *p = &buf[19];
bool negative = n < 0;
+ if (negative) n = -n; // Safe to do because we checked for INT64_MIN earlier
do {
*(p--) = '0' + (n % 10);