From 630897b7793ef4f6d3be3607790209b862ea3179 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 8f79e75..52af7b6 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) {