delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/04/26/11:33:21

From: <ams AT ludd DOT luth DOT se>
Message-Id: <200304261506.h3QF6Whp013579@speedy.ludd.luth.se>
Subject: Re: Yet another try on nan in strto{f,d,ld}
In-Reply-To: <200304221232.OAA06267@lws256.lu.erisoft.se> "from Martin Stromberg
at Apr 22, 2003 02:32:06 pm"
To: djgpp-workers AT delorie DOT com
Date: Sat, 26 Apr 2003 17:06:32 +0200 (CEST)
X-Mailer: ELM [version 2.4ME+ PL78 (25)]
MIME-Version: 1.0
X-MailScanner: Found to be clean
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Eli said:
> Btw, is code such as this:
> 
>      double tmp_d = NAN;
> 
> safe when numerical exceptions are unmasked in the FP control word?

I made this program:

#include <float.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int
main (void)
{
  double d;

  printf("FPU CW: 0x%08x.\n", _control87(0, 0));
  
  d = NAN;
  printf("d = %.20g.\n", d);

  /* Fault on FPU exception. */
  _control87(0, 0x3f);
  printf("FPU CW: 0x%08x.\n", _control87(0, 0));

  d = NAN;
  printf("d = %.20g.\n", d);

  return(EXIT_SUCCESS);
}

When run, it says:

FPU CW: 0x0000037f.
d = NaN.
FPU CW: 0x00000340.
d = NaN.

I. e. no crash traceback. Does that answer the question?


Right,

						MartinS

- Raw text -


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