diff options
| author | 2025-12-05 12:54:11 +0100 | |
|---|---|---|
| committer | 2025-12-05 12:54:11 +0100 | |
| commit | 78333412a9b502ebd04306ecfd71b0db216d51c7 (patch) | |
| tree | d037098457bb7165356da2f68a64b3cc1401c73a | |
| parent | 139dfbd9b812757f0070745f93624c95ea902615 (diff) | |
io: print nans as NaN
| -rw-r--r-- | io.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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"); |