From mboxrd@z Thu Jan 1 00:00:00 1970 Path: quimby.gnus.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: Converting NaN to integer 0. Date: Tue, 12 Feb 2002 13:43:42 -0800 (PST) Message-ID: <200202122143.g1CLhgq11763@shade.twinsun.com> References: <200202110253.g1B2r5E10557@swt40.swt.com> <200202121524.g1CFOhK07421@aztec.santafe.edu> NNTP-Posting-Host: quimby2.netfonds.no X-Trace: quimby2.netfonds.no 1013551000 29423 195.204.10.66 (12 Feb 2002 21:56:40 GMT) X-Complaints-To: usenet@quimby2.netfonds.no NNTP-Posting-Date: 12 Feb 2002 21:56:40 GMT Cc: emacs-devel@gnu.org Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby2.netfonds.no with esmtp (Exim 3.12 #1 (Debian)) id 16akuk-0007eQ-00 for ; Tue, 12 Feb 2002 22:56:39 +0100 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.33 #1 (Debian)) id 16akje-0005RS-00; Tue, 12 Feb 2002 16:45:10 -0500 Original-Received: from alcor.twinsun.com ([198.147.65.9]) by fencepost.gnu.org with esmtp (Exim 3.33 #1 (Debian)) id 16akiQ-0005Mu-00; Tue, 12 Feb 2002 16:43:55 -0500 Original-Received: from shade.twinsun.com ([192.54.239.27]) by alcor.twinsun.com (8.12.1/8.12.1) with ESMTP id g1CLhhCO014134; Tue, 12 Feb 2002 13:43:47 -0800 (PST) Original-Received: (eggert@localhost) by shade.twinsun.com (8.11.6+Sun/8.11.6) id g1CLhgq11763; Tue, 12 Feb 2002 13:43:42 -0800 (PST) Original-To: rms@gnu.org In-reply-to: <200202121524.g1CFOhK07421@aztec.santafe.edu> (rms@gnu.org) Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.5 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: quimby.gnus.org gmane.emacs.devel:1050 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:1050 > From: Richard Stallman > Date: Tue, 12 Feb 2002 08:24:43 -0700 (MST) > > Does anyone know what is the "correct" thing to do in this case > according to IEEE? ANSI/IEEE Std 754-1985 section 7.1 says: The invalid operation exception is signaled if an operand is invalid for the operation to be performed. The result, when the exception occurs without a trap, shall be a quiet NaN (6.2) provided the destination has a floating-point format. The invalid operations are ... (7) Conversion of a binary floating-point number to an integer or decimal format when overflow, infinity, or NaN precludes a faithful representation in that format and this cannot otherwise be signaled > Would returning NaN be correct? Yes, if you decide that the destination format is a Lisp object, since a Lisp object can faithfully represent NaN. Similarly, it would be correct to return +-infinity for infinities and for floating-point numbers that are too large to represent in the destination integer format. However, if you decide that the destination format must be an integer Lisp object (i.e. that it cannot be a floating-point Lisp object), then the ANSI/IEEE 754 is silent about what integer is returned for NaNs, infinities, and out-of-range floating-point numbers. The ISO C 99 standard agrees with ANSI/IEEE 754 here. It says that on a host that uses IEEE floating point, when a NaN or out-of-range value is converted to an (necessarily fixed-width) integer, the invalid operation exception is raised and the resulting integer value is unspecified. _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://mail.gnu.org/mailman/listinfo/emacs-devel