From db822918917c96f31067249dc915fd4a5936b069 Mon Sep 17 00:00:00 2001 From: David Mak Date: Mon, 9 Oct 2023 16:02:15 +0800 Subject: [PATCH] standalone: Do not output sign if float is NaN Matches behavior in Python. --- nac3standalone/demo/demo.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nac3standalone/demo/demo.c b/nac3standalone/demo/demo.c index fb112d8..ef80b74 100644 --- a/nac3standalone/demo/demo.c +++ b/nac3standalone/demo/demo.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -33,7 +34,11 @@ void output_uint64(uint64_t x) { } void output_float64(double x) { - printf("%f\n", x); + if (isnan(x)) { + puts("nan"); + } else { + printf("%f\n", x); + } } void output_asciiart(int32_t x) {