mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-12 10:44:12 -08:00
(float_to_string): Handle infinities and NaN specially.
This commit is contained in:
parent
eb659c4114
commit
7f45de2dfc
1 changed files with 20 additions and 0 deletions
20
src/print.c
20
src/print.c
|
|
@ -956,6 +956,26 @@ float_to_string (buf, data)
|
|||
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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue