delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/11/08/07:52:04

Date: Sun, 8 Nov 1998 14:50:47 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: djgpp-workers AT delorie DOT com
Subject: doprnt.c patch for NaN
Message-ID: <Pine.SUN.3.91.981108144925.13039E-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com

This allows to print +/-NaN with "%+f".

*** src/libc/ansi/stdio/doprnt.c~0	Sun Sep 27 15:23:10 1998
--- src/libc/ansi/stdio/doprnt.c	Fri Nov  6 19:02:18 1998
*************** _doprnt(const char *fmt0, va_list argp, 
*** 266,274 ****
        /*
         * If the format specifier requested an explicit sign,
         * we print a negative sign even if no significant digits
!        * will be shown.  In other words, "%+f" might yield -0.000000.
         */
!       if (!nan && (softsign || (sign == '+' && neg_ldouble)))
  	sign = '-';
        nan = 0;
        t = *buf ? buf : buf + 1;
--- 266,275 ----
        /*
         * If the format specifier requested an explicit sign,
         * we print a negative sign even if no significant digits
!        * will be shown, and we also print a sign for a NaN.  In
!        * other words, "%+f" might print -0.000000, +NaN and -NaN.
         */
!       if (softsign || (sign == '+' && (neg_ldouble || nan == -1)))
  	sign = '-';
        nan = 0;
        t = *buf ? buf : buf + 1;
*************** isspeciall(long double d, char *bufp)
*** 867,874 ****
    if ((ip->manh & 0x7fffffff) || ip->manl)
    {
      strcpy(bufp, "NaN");
!     nan = 1;			/* kludge: we don't need the sign,  it's not nice
! 				   but it should work */
    }
    else
      (void)strcpy(bufp, "Inf");
--- 868,875 ----
    if ((ip->manh & 0x7fffffff) || ip->manl)
    {
      strcpy(bufp, "NaN");
!     nan = ip->sign ? -1 : 1; /* kludge: we don't need the sign,  it's not nice
! 				but it should work */
    }
    else
      (void)strcpy(bufp, "Inf");

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019