diff options
-rw-r--r-- | src/data.c | 4 | ||||
-rw-r--r-- | src/floatfns.c | 7 | ||||
-rw-r--r-- | src/print.c | 20 |
3 files changed, 6 insertions, 25 deletions
diff --git a/src/data.c b/src/data.c index c8beeda7208..aaccb675183 100644 --- a/src/data.c +++ b/src/data.c @@ -2812,10 +2812,6 @@ arith_driver (enum arithop code, ptrdiff_t nargs, Lisp_Object *args) return val; } -#ifndef isnan -# define isnan(x) ((x) != (x)) -#endif - static Lisp_Object float_arith_driver (double accum, ptrdiff_t argnum, enum arithop code, ptrdiff_t nargs, Lisp_Object *args) diff --git a/src/floatfns.c b/src/floatfns.c index e7d404a84e0..45e786f9669 100644 --- a/src/floatfns.c +++ b/src/floatfns.c @@ -47,13 +47,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ #include <count-leading-zeros.h> -#ifndef isfinite -# define isfinite(x) ((x) - (x) == 0) -#endif -#ifndef isnan -# define isnan(x) ((x) != (x)) -#endif - /* Check that X is a floating point number. */ static void diff --git a/src/print.c b/src/print.c index 71591952a23..da6ec1aaedf 100644 --- a/src/print.c +++ b/src/print.c @@ -38,6 +38,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ #include <c-ctype.h> #include <float.h> #include <ftoastr.h> +#include <math.h> #ifdef WINDOWSNT # include <sys/socket.h> /* for F_DUPFD_CLOEXEC */ @@ -1001,23 +1002,14 @@ float_to_string (char *buf, double data) int width; int len; - /* Check for plus infinity in a way that won't lose - if there is no plus infinity. */ - if (data == data / 2 && data > 1.0) - { - static char const infinity_string[] = "1.0e+INF"; - strcpy (buf, infinity_string); - return sizeof infinity_string - 1; - } - /* Likewise for minus infinity. */ - if (data == data / 2 && data < -1.0) + if (isinf (data)) { static char const minus_infinity_string[] = "-1.0e+INF"; - strcpy (buf, minus_infinity_string); - return sizeof minus_infinity_string - 1; + bool positive = 0 < data; + strcpy (buf, minus_infinity_string + positive); + return sizeof minus_infinity_string - 1 - positive; } - /* Check for NaN in a way that won't fail if there are no NaNs. */ - if (! (data * 0.0 >= 0.0)) + if (isnan (data)) { /* Prepend "-" if the NaN's sign bit is negative. The sign bit of a double is the bit that is 1 in -0.0. */ |