delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/04/22/09:23:43

Sender: rich AT phekda DOT freeserve DOT co DOT uk
Message-ID: <3EA53A32.8CA70A7F@phekda.freeserve.co.uk>
Date: Tue, 22 Apr 2003 13:48:50 +0100
From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.23 i586)
X-Accept-Language: de,fr
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
Subject: Re: Long double confusion
References: <200304171703 DOT h3HH307q016727 AT speedy DOT ludd DOT luth DOT se> <2110-Sat19Apr2003102338+0300-eliz AT elta DOT co DOT il>
Reply-To: djgpp-workers AT delorie DOT com

Hello.

Eli Zaretskii wrote:
> 
> > From: <ams AT ludd DOT luth DOT se>
> > Date: Thu, 17 Apr 2003 19:03:00 +0200 (CEST)
> >
> > My readings on the net doesn't show what a long double with it
> > exponent set to 0x7fff and a _cleared_ most significant bit in the
> > mantissa is. The most significant bit for a long double is the
> > integer bit (which isn't present in floats or doubles).
> >
> > As far as I understand a long double with exponent == 0 and with
> > the most significant bit in the mantissa cleared is a denormal (which
> > isn't a NaN but a value close to 0).
> >
> > But I don't know what to make of it when exponent != 0.
> >
> > Are they all NaNs? Only the ones with exponent == 0x7fff? Or none of
> > them?
> 
> See section 7.4.4 of the Intel Manual: it calls those numbers
> "unnormals".
> 
> Such numbers are generally a result of interpreting arbitrary bit
> patterns as FP numbers (a.k.a. "bugs").
> 
> IIRC, our _doprnt has special support for those.

Yes, it does. From isspeciall:

  /* Unnormals: the MSB of mantissa is non-zero, but the exponent is
     not zero either.  */
  if ((ip->manh & 0x80000000U) == 0 && ip->exp != 0)
  {
    if (ip->sign)
      *bufp++ = '-';
    strcpy(bufp, UNNORMAL_REP);
    return strlen(bufp) + ip->sign;
  }

ip is a long double cast into the IEEE split-format struct: (high mantissa,
low mantissa, exponent, sign). UNNORMAL_REP is "Unnormal".

Bye, Rich =]

-- 
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]

- Raw text -


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