From owner-freebsd-numerics@FreeBSD.ORG Wed Jun 5 16:06:01 2013 Return-Path: Delivered-To: numerics@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 36B71488 for ; Wed, 5 Jun 2013 16:06:01 +0000 (UTC) (envelope-from das@CSAIL.MIT.EDU) Received: from zim.MIT.EDU (50-196-151-174-static.hfc.comcastbusiness.net [50.196.151.174]) by mx1.freebsd.org (Postfix) with ESMTP id 1D6B610FC for ; Wed, 5 Jun 2013 16:06:00 +0000 (UTC) Received: from zim.MIT.EDU (localhost [127.0.0.1]) by zim.MIT.EDU (8.14.7/8.14.2) with ESMTP id r55G5xZ7044481; Wed, 5 Jun 2013 09:05:59 -0700 (PDT) (envelope-from das@CSAIL.MIT.EDU) Received: (from das@localhost) by zim.MIT.EDU (8.14.7/8.14.2/Submit) id r55G5wYK044480; Wed, 5 Jun 2013 09:05:58 -0700 (PDT) (envelope-from das@CSAIL.MIT.EDU) Date: Wed, 5 Jun 2013 09:05:58 -0700 From: David Schultz To: Bruce Evans Subject: Re: isinf() on NaN args Message-ID: <20130605160558.GA44189@zim.MIT.EDU> References: <20130605183354.V1244@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130605183354.V1244@besplex.bde.org> Cc: numerics@freebsd.org X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2013 16:06:01 -0000 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.