From f148d861cb69419378d9e3ca4d9816f98e0a1cff Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 25 May 2025 15:47:03 -0400 Subject: Bugfix for converting negative integers to text --- src/stdlib/integers.c | 4 ++++ 1 file changed, 4 insertions(+) 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); -- cgit v1.2.3