delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/05/16/10:19:31

Date: Tue, 16 May 2000 09:09:44 -0500
From: Eric Rudd <rudd AT cyberoptics DOT com>
Subject: Re: Math functions
To: djgpp-workers AT delorie DOT com
Message-id: <392156A8.EFC5622A@cyberoptics.com>
Organization: CyberOptics
MIME-version: 1.0
X-Mailer: Mozilla 4.72 [en] (Win95; U)
X-Accept-Language: en
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1000516142823 DOT 24814B AT is>
Reply-To: djgpp-workers AT delorie DOT com

Eli Zaretskii wrote:

> > When you "silently" return a NaN, say by log(-1.0), the bit will not
> > be set in the status word.
>
> Are you sure?  The Intel manual seems to say otherwise: it says that any
> invalid operation sets the appropriate bit in the status word.

One can generate a NaN by an invalid operation, but it does not follow that
invalid operations are the *only* way to generate a NaN.  According to Intel,
there are "signaling NaNs" and "quiet NaNs", and only the signaling NaNs cause
an exception.  In my elementary functions I return a NaN by loading it, rather
than generating it, and it's always a QNaN, rather than an SNaN; that way, the
question of exceptions never arises.  Here is a quote from a draft of C99 that
agrees with the way QNaNs behave on x87 processors:

     5.2.4.2.2  Characteristics of floating types <float.h>

     [#3]  Floating  types  may  include  values  that  are   not
     normalized  floating-point  numbers,  for  example subnormal
     floating-point numbers (x!=0,e=emin,f1=0),  infinities,  and
     NaNs.15)  A NaN is an encoding signifying  Not-a-Number.   A quiet
     NaN   propagates  through  almost  every  arithmetic operation
     without raising  an  exception;  a  signaling  NaN generally
     raises   an   exception  when  occurring  as  an arithmetic
     operand.16)

-Eric Rudd
rudd AT cyberoptics DOT com

- Raw text -


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