diff options
Diffstat (limited to 'src/print.c')
| -rw-r--r-- | src/print.c | 20 |
1 files changed, 6 insertions, 14 deletions
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/>. */ | |||
| 38 | #include <c-ctype.h> | 38 | #include <c-ctype.h> |
| 39 | #include <float.h> | 39 | #include <float.h> |
| 40 | #include <ftoastr.h> | 40 | #include <ftoastr.h> |
| 41 | #include <math.h> | ||
| 41 | 42 | ||
| 42 | #ifdef WINDOWSNT | 43 | #ifdef WINDOWSNT |
| 43 | # include <sys/socket.h> /* for F_DUPFD_CLOEXEC */ | 44 | # include <sys/socket.h> /* for F_DUPFD_CLOEXEC */ |
| @@ -1001,23 +1002,14 @@ float_to_string (char *buf, double data) | |||
| 1001 | int width; | 1002 | int width; |
| 1002 | int len; | 1003 | int len; |
| 1003 | 1004 | ||
| 1004 | /* Check for plus infinity in a way that won't lose | 1005 | if (isinf (data)) |
| 1005 | if there is no plus infinity. */ | ||
| 1006 | if (data == data / 2 && data > 1.0) | ||
| 1007 | { | ||
| 1008 | static char const infinity_string[] = "1.0e+INF"; | ||
| 1009 | strcpy (buf, infinity_string); | ||
| 1010 | return sizeof infinity_string - 1; | ||
| 1011 | } | ||
| 1012 | /* Likewise for minus infinity. */ | ||
| 1013 | if (data == data / 2 && data < -1.0) | ||
| 1014 | { | 1006 | { |
| 1015 | static char const minus_infinity_string[] = "-1.0e+INF"; | 1007 | static char const minus_infinity_string[] = "-1.0e+INF"; |
| 1016 | strcpy (buf, minus_infinity_string); | 1008 | bool positive = 0 < data; |
| 1017 | return sizeof minus_infinity_string - 1; | 1009 | strcpy (buf, minus_infinity_string + positive); |
| 1010 | return sizeof minus_infinity_string - 1 - positive; | ||
| 1018 | } | 1011 | } |
| 1019 | /* Check for NaN in a way that won't fail if there are no NaNs. */ | 1012 | if (isnan (data)) |
| 1020 | if (! (data * 0.0 >= 0.0)) | ||
| 1021 | { | 1013 | { |
| 1022 | /* Prepend "-" if the NaN's sign bit is negative. | 1014 | /* Prepend "-" if the NaN's sign bit is negative. |
| 1023 | The sign bit of a double is the bit that is 1 in -0.0. */ | 1015 | The sign bit of a double is the bit that is 1 in -0.0. */ |