Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Jun 2013 09:05:58 -0700
From:      David Schultz <das@CSAIL.MIT.EDU>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        numerics@freebsd.org
Subject:   Re: isinf() on NaN args
Message-ID:  <20130605160558.GA44189@zim.MIT.EDU>
In-Reply-To: <20130605183354.V1244@besplex.bde.org>
References:  <20130605183354.V1244@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Jun 05, 2013, Bruce Evans wrote:
> Is isinf(x) (or even fpclassify(x)) permitted to raise FE_INVALID if
> x is a (quiet) NaN?  It shouldn't, but I can't find where C99 requires
> this.  I can only find where C99 requires FE_INVALID to not be raised
> for comparison macros.
> 
> It should raise if x is a signaling NaN, but C99 doesn't specify
> signaling NaNs and the hardware behaviour is more varied and the
> software bugs are larger for signaling NaNs, so getting this wrong in
> many cases doesn't matter much.

The equivalent operation in IEEE-754R never raises an exception,
even for signaling NaNs.  If we ignore signaling NaNs for a
moment, I think the general idea is to raise an invalid exception
in two situations:

 1. at the moment when a NaN is produced from non-NaN inputs
    (this is similar to the rule that overflow is raised only
    when the overflow first occurs)

 2. for operations that don't return a floating-point result,
    whenever there's no sensible answer to return

The second case covers things like conversion to integer, ilogb,
and comparison operators.  One could argue that classification
macros like isinf() always have a sensible true or false answer,
though, because you're asking a question about what kind of value
you have.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130605160558.GA44189>