Printf prints NaN for -Inf
J. Johnston
jjohnstn@redhat.com
Tue Nov 12 14:16:00 GMT 2002
Peter Kabal wrote:
>
> I am running gcc 3.2 under Cygwin. I am told that the printf routine
> comes from newlib.
>
> The function call log(0) returns the bit pattern for -Inf, but if this
> value is given to printf, the printout says "NaN". [printf ("%g\n",
> log(0)];
>
> Peter Kabal Kabal@ECE.McGill.CA (514) 398-7130
> Electrical & Computer Engineering (514) 398-4470 (FAX)
> McGill University
> 3480 University, Montreal, Quebec, Canada H3A 2A7
The attached patch has been checked in.
-- Jeff J.
-------------- next part --------------
Index: libc/stdlib/ldtoa.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdlib/ldtoa.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- libc/stdlib/ldtoa.c 5 Feb 2002 17:14:35 -0000 1.5
+++ libc/stdlib/ldtoa.c 12 Nov 2002 21:47:53 -0000 1.6
@@ -1859,7 +1859,7 @@
#ifdef INFINITY
/* Point to the exponent field. */
p = &yy[NE-1];
-if( *p == 0x7fff )
+if( (*p & 0x7fff) == 0x7fff )
{
#ifdef NANS
#ifdef IBMPC
More information about the Newlib
mailing list