standalone: Do not output sign if float is NaN

Matches behavior in Python.
This commit is contained in:
David Mak 2023-10-09 16:02:15 +08:00
parent e546535df0
commit 630897b779
1 changed files with 6 additions and 1 deletions

View File

@ -1,3 +1,4 @@
#include <math.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
@ -33,7 +34,11 @@ void output_uint64(uint64_t x) {
} }
void output_float64(double x) { void output_float64(double x) {
if (isnan(x)) {
puts("nan");
} else {
printf("%f\n", x); printf("%f\n", x);
}
} }
void output_asciiart(int32_t x) { void output_asciiart(int32_t x) {