From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: Equality predicates, signed zeroes, R5RS and R6RS Date: Mon, 31 Jan 2011 14:53:29 -0500 Message-ID: <87k4hkyhmu.fsf@yeeloong.netris.org> References: <20110131185050.9C10F98298@pluto.mumble.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1296504295 11074 80.91.229.12 (31 Jan 2011 20:04:55 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 31 Jan 2011 20:04:55 +0000 (UTC) Cc: Andy Wingo , Taylor R Campbell To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Jan 31 21:04:50 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PjzzW-0005hE-80 for guile-devel@m.gmane.org; Mon, 31 Jan 2011 21:04:50 +0100 Original-Received: from localhost ([127.0.0.1]:38898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PjzzV-0002no-B4 for guile-devel@m.gmane.org; Mon, 31 Jan 2011 15:04:49 -0500 Original-Received: from [140.186.70.92] (port=54133 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pjzow-0008NG-J0 for guile-devel@gnu.org; Mon, 31 Jan 2011 14:54:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pjzof-0006Wr-OQ for guile-devel@gnu.org; Mon, 31 Jan 2011 14:53:54 -0500 Original-Received: from world.peace.net ([216.204.32.208]:36102) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pjzof-0006WQ-Kw for guile-devel@gnu.org; Mon, 31 Jan 2011 14:53:37 -0500 Original-Received: from ip68-9-118-38.ri.ri.cox.net ([68.9.118.38] helo=freedomincluded) by world.peace.net with esmtpa (Exim 4.69) (envelope-from ) id 1Pjzoa-0002OU-3a; Mon, 31 Jan 2011 14:53:32 -0500 Original-Received: from mhw by freedomincluded with local (Exim 4.69) (envelope-from ) id 1PjzoY-0001lQ-1g; Mon, 31 Jan 2011 14:53:30 -0500 In-Reply-To: <20110131185050.9C10F98298@pluto.mumble.net> (Taylor R. Campbell's message of "Mon, 31 Jan 2011 18:50:48 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 216.204.32.208 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:11455 Archived-At: An issue has come to my attention that deserves wider discussion. Since at least Guile 1.8, (=3D 0.0 -0.0) has returned #t but (eqv? 0.0 -0.0) has returned #f, and this is still the case. PLT Scheme agrees with us that (eqv? 0.0 -0.0) is #f, but MIT/GNU Scheme, SCM, Chicken, and Gauche all return #t in this case. Our current behavior violates the R5RS but is required by the R6RS. The R5RS requires that `eqv?' and `=3D' must agree for numbers of the same exactness. The R6RS requires that `eqv?' must return #f for arguments that yield different results (in the sense of eqv?) when passed as arguments to any other procedure that can be defined as a finite composition of Scheme=E2=80= =99s standard arithmetic procedures. Since the R6RS also requires that (/ 0.0) yields +inf.0, and IEEE 754 requires not only this but also that (/ -0.0) yields -inf.0, that implies that (eqv? 0.0 -0.0) must be #f. IEEE 754 also requires that (=3D 0.0 -0.0) must return #t, and indeed this is the only sane option. Therefore I see no way to be compliant with both the R5RS and the R6RS at the same time. Personally, although I don't agree with the R6RS on everything, I think they got this part right. It's useful to have an equality predicate that can distinguish numbers that are distinguishable by other numerical operations. Given that everyone agrees that `eqv?' must distinguish 0 from 0.0, it is already not useful as a numerical `=3D'. Any program that uses it this way is asking for trouble. Therefore, I don't have qualms about keeping our existing behavior, namely that (eqv? 0.0 -0.0) returns #f. What do you think? Mark