From 78333412a9b502ebd04306ecfd71b0db216d51c7 Mon Sep 17 00:00:00 2001 From: lemon Date: Fri, 5 Dec 2025 12:54:11 +0100 Subject: io: print nans as NaN --- io.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/io.c b/io.c index 1721f7b..6e1d425 100644 --- a/io.c +++ b/io.c @@ -291,6 +291,11 @@ putdouble(struct wbuf *buf, double x, vlong prec) x = -x; } + if (x != x) { + iowrite(buf, "NaN", 3); + return n + 3; + } + x += 0.5 / prec; // round last decimal if (x >= (double)(-1ULL>>1)) { // out of range? n += bwriteS(buf, "inf"); -- cgit v1.2.3