From mboxrd@z Thu Jan 1 00:00:00 1970 Path: quimby.gnus.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel Subject: Re: Converting NaN to integer 0. Date: Tue, 12 Feb 2002 10:46:29 -0600 (CST) Message-ID: <200202121646.KAA12400@eel.dms.auburn.edu> References: <200202110253.g1B2r5E10557@swt40.swt.com> <200202121524.g1CFOhK07421@aztec.santafe.edu> NNTP-Posting-Host: quimby2.netfonds.no X-Trace: quimby2.netfonds.no 1013533161 15545 195.204.10.66 (12 Feb 2002 16:59:21 GMT) X-Complaints-To: usenet@quimby2.netfonds.no NNTP-Posting-Date: 12 Feb 2002 16:59:21 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 16agH2-00042d-00 for ; Tue, 12 Feb 2002 17:59:20 +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 16ag6V-0005Og-00; Tue, 12 Feb 2002 11:48:27 -0500 Original-Received: from manatee.dms.auburn.edu ([131.204.53.104]) by fencepost.gnu.org with esmtp (Exim 3.33 #1 (Debian)) id 16ag4O-0005E3-00; Tue, 12 Feb 2002 11:46:17 -0500 Original-Received: from eel.dms.auburn.edu (eel.dms.auburn.edu [131.204.53.108]) by manatee.dms.auburn.edu (8.9.1a/8.9.1) with ESMTP id KAA14521; Tue, 12 Feb 2002 10:46:11 -0600 (CST) Original-Received: (from teirllm@localhost) by eel.dms.auburn.edu (8.9.3+Sun/8.9.3) id KAA12400; Tue, 12 Feb 2002 10:46:29 -0600 (CST) X-Authentication-Warning: eel.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: rms@gnu.org In-reply-to: <200202121524.g1CFOhK07421@aztec.santafe.edu> (message from Richard Stallman on Tue, 12 Feb 2002 08:24:43 -0700 (MST)) 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:1045 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:1045 Richard Stallman wrote: Does anyone know what is the "correct" thing to do in this case according to IEEE? Would returning NaN be correct? The functiona ffloor, fceiling, ftruncate and fround all return (I believe correctly) NaN when passed NaN. They also return +INF or -INF when passed those values. The trouble with floor, ceiling, truncate and round seems to be that these functions are supposed to return an integer, and NaN and the infinities are floats, not integers. So the problem is not what the rounded value of NaN should be, that would clearly seem to be NaN, but whether it makes sense to cast NaN to an integer. I do not know what the IEEE floating point standard says about casting these values to integers. It is not guaranteed to say anything about it, since it is a floating point standard. The rounding functions in the GNU C library that return a floating point number all behave like ffloor et al. The rounding functions that return integers (lrint and lround) seem to return nonsense values when fed NAN or infinities. So does trying to cast NAN or an infinity to int. floor, ceiling, truncate and round all produce an error when passed infinity, I guess because the logical rounded value returned by ffloor et al is not an integer. Unless the IEEE standard says something else, it would seem consistent to give an error message when NaN is passed since the logical rounded value (NaN) returned by ffloor et al is not an integer either. It seems like somebody who expects NaN to be rounded to Nan would call ffloor or similar, because he would not be insisting on an integer result. _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://mail.gnu.org/mailman/listinfo/emacs-devel