# HG changeset patch # User Richard M. Stallman # Date 886381775 0 # Node ID 6397d7a972776c571b2249eed30c7767f727d0ca # Parent d5ae7491d2b0114be109e101685ba55379f9bd3d (float_to_string): Handle infinities and NaN specially. diff -r d5ae7491d2b0 -r 6397d7a97277 src/print.c --- a/src/print.c Mon Feb 02 01:08:52 1998 +0000 +++ b/src/print.c Mon Feb 02 01:09:35 1998 +0000 @@ -956,6 +956,26 @@ unsigned char *cp; int width; + /* Check for plus infinity in a way that won't lose + if there is no plus infinity. */ + if (data == data / 2 && data > 1.0) + { + strcpy (buf, "1.0e+INF"); + return; + } + /* Likewise for minus infinity. */ + if (data == data / 2 && data < -1.0) + { + strcpy (buf, "-1.0e+INF"); + return; + } + /* Check for NaN in a way that won't fail if there are no NaNs. */ + if (! (data * 0.0 >= 0.0)) + { + strcpy (buf, "0.0e+NaN"); + return; + } + if (NILP (Vfloat_output_format) || !STRINGP (Vfloat_output_format)) lose: