Bladeren bron

stdio: output sign with NaNs

Output NaN sign similar to what glibc does.
NaN cannot be compared with 0, so use signbit() to figure out the sign.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Max Filippov 1 maand geleden
bovenliggende
commit
bd0e782c90
1 gewijzigde bestanden met toevoegingen van 3 en 0 verwijderingen
  1. 3 0
      libc/stdio/_fpmaxtostr.c

+ 3 - 0
libc/stdio/_fpmaxtostr.c

@@ -10,6 +10,7 @@
 #include <printf.h>
 #include <float.h>
 #include <locale.h>
+#include <math.h>
 #include "_fpmaxtostr.h"
 
 /*
@@ -250,6 +251,8 @@ ssize_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info,
 	pc_fwi[5] = INF_OFFSET;
 	if (isnan(x)) {				/* First, check for nan. */
 		pc_fwi[5] = NAN_OFFSET;
+		if (signbit(x))
+			*sign_str = '-';
 		goto INF_NAN;
 	}