This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
Re: Printf prints NaN for -Inf
- From: "J. Johnston" <jjohnstn at redhat dot com>
- To: Peter Kabal <kabal at ECE dot McGill dot CA>
- Cc: newlib at sources dot redhat dot com
- Date: Tue, 12 Nov 2002 17:16:11 -0500
- Subject: Re: Printf prints NaN for -Inf
- Organization: Red Hat Inc.
- References: <000601c28a5c$22466be0$a82ace84@research.pc.ece.mcgill.ca>
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.
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