delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/03/22/04:30:27

Date: Wed, 22 Mar 2000 10:27:55 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Dieter Buerssner <buers AT gmx DOT de>
cc: djgpp-workers AT delorie DOT com
Subject: Re: Unnormals???
In-Reply-To: <200003201825.UAA28340@is.elta.co.il>
Message-ID: <Pine.SUN.3.91.1000322102606.17945E-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: dj-admin AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Mon, 20 Mar 2000, Dieter Buerssner wrote:

> with my version of _doprnt. 
> 
> The original version has a bug in isspeciall, so it prints +unnormal, 
> --unnormal

By ``bug'' what exactly do you mean?  The double minus sign is indeed
a bug, but the "unnormal" part isn't, I think.

> static const unsigned short pos_nanshort[] = {0,0,0,1,0x7fff,0};
> static const unsigned short neg_nanshort[] = {0,0,0,1,0xffff,0};

When converted to a long double, these two have the following bit
patterns:

	pos_nanshort = 7fff 0001 0000 0000
	neg_nanshort = ffff 0001 0000 0000

These are indeed unnormals: their mantissa has a zero MSB.

If you wanted _doprnt to support so-called pseudo-NaNs, as described
in section 7.4.4 of the Intel manual, then we indeed need to reserve
the 0x7fff exponent for a NaN.  But _doprnt currently doesn't support
pseudo-NaNs (and I'm not sure it should).

To generate a supported NaN, you might try something like this:

  static const unsigned short pos_nanshort[] = {0,0,0,0xC000,0x7fff,0};
  static const unsigned short neg_nanshort[] = {0,0,0,0xC000,0xffff,0};

These generate a positive QNaN and the real indefinite.  If you want a
signalling NaN (SNaN), try these:

  static const unsigned short pos_nanshort[] = {0,0,0,0x8001,0x7fff,0};
  static const unsigned short neg_nanshort[] = {0,0,0,0x8001,0xffff,0};

- Raw text -


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