py/formatfloat: Don't print the negative sign of a NaN value.
NaN may have the sign bit set but it has no meaning, so don't print it out.
diff --git a/py/formatfloat.c b/py/formatfloat.c
index 35cd5d5..b61a958 100644
--- a/py/formatfloat.c
+++ b/py/formatfloat.c
@@ -30,6 +30,7 @@
#include <assert.h>
#include <stdlib.h>
#include <stdint.h>
+#include <math.h>
#include "py/formatfloat.h"
/***********************************************************************
@@ -82,7 +83,6 @@
#define FPROUND_TO_ONE 0.999999999995
#define FPDECEXP 256
#define FPMIN_BUF_SIZE 7 // +9e+199
-#include <math.h>
#define fp_signbit(x) signbit(x)
#define fp_isspecial(x) 1
#define fp_isnan(x) isnan(x)
@@ -122,7 +122,7 @@
}
return buf_size >= 2;
}
- if (fp_signbit(f)) {
+ if (fp_signbit(f) && !isnan(f)) {
*s++ = '-';
f = -f;
} else {