delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/01/19/08:34:56

Date: Tue, 19 Jan 1999 08:33:58 -0500 (EST)
From: Stephen L Moshier <moshier AT mediaone DOT net>
X-Sender: moshier AT moshier DOT ne DOT mediaone DOT net
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
cc: Robert Hoehne <robert DOT hoehne AT gmx DOT net>, djgpp-workers AT delorie DOT com,
"K.B. Williams" <Kbwms AT aol DOT com>
Subject: Re: Bug when printing long doubles
In-Reply-To: <Pine.SUN.3.91.990119112518.12893G-100000@is>
Message-ID: <Pine.LNX.4.05.9901190824270.16892-100000@moshier.ne.mediaone.net>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com

I'm pretty sure the Intel coprocessor manual will say that is an invalid
bit pattern, because the most significant bit of the significand is
not set while the exponent is something other than 0 or 7fff.  Try
adding zero to it, as in the following.  The coprocessor should turn
it into a NaN pattern.

#include <stdio.h>
unsigned char i[10] =
{
  0x13,
  0x22,
  0xf7,
  0xfc,
  0x2f,
  0x3e,
  0x28,
  0x6f,
  0x3a,
  0xa3};

int 
main ()
{
  char buf[100];
  union
    {
      unsigned char c[12];
      long double dd;
    }
  u;
  long double dd2;
  int k;

  for (k = 0; k < 10; k++)
    u.c[k] = i[k];
  dd2 = u.dd + 0.0;
  sprintf (buf, "%*.17LG", 16, dd2);
  fprintf (stderr, "%s\n", buf);
  return 0;
}


- Raw text -


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