From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Peter Whaite Newsgroups: gmane.emacs.devel Subject: Fix for inconsistent (/ DIVIDEND DIVISOR &rest DIVISORS) Date: Tue, 04 May 2004 18:27:11 -0400 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200405042227.i44MRBME009469@brains.moreideas.ca> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1083712567 24467 80.91.224.253 (4 May 2004 23:16:07 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 4 May 2004 23:16:07 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Wed May 05 01:15:58 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BL98o-0007yh-00 for ; Wed, 05 May 2004 01:15:58 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BL98o-0004D0-00 for ; Wed, 05 May 2004 01:15:58 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BL8Zm-0004lB-IX for emacs-devel@quimby.gnus.org; Tue, 04 May 2004 18:39:46 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BL8Z3-0004ju-Qc for emacs-devel@gnu.org; Tue, 04 May 2004 18:39:01 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BL8YX-0004W4-CW for emacs-devel@gnu.org; Tue, 04 May 2004 18:39:00 -0400 Original-Received: from [199.185.220.220] (helo=priv-edtnes57.telusplanet.net) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BL8OK-0001w3-Ve for emacs-devel@gnu.org; Tue, 04 May 2004 18:27:57 -0400 Original-Received: from brains.moreideas.ca ([142.169.171.18]) by priv-edtnes57.telusplanet.net (InterMail vM.6.00.05.02 201-2115-109-103-20031105) with ESMTP id <20040504222744.WFHI15682.priv-edtnes57.telusplanet.net@brains.moreideas.ca> for ; Tue, 4 May 2004 16:27:44 -0600 Original-Received: from brains.moreideas.ca (localhost.localdomain [127.0.0.1]) by brains.moreideas.ca (8.12.8/8.12.8) with ESMTP id i44MRBI6009473 for ; Tue, 4 May 2004 18:27:11 -0400 Original-Received: from brains.moreideas.ca (peta@localhost) by brains.moreideas.ca (8.12.8/8.12.8/Submit) with ESMTP id i44MRBME009469 for ; Tue, 4 May 2004 18:27:11 -0400 Original-To: emacs-devel@gnu.org X-Mailer: MH-E 7.4.3+cvs; nmh 1.0.4; GNU Emacs 21.3.50.41 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:22772 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:22772 Some time ago there was a thread on division being inconsistent when floats were involved. I dont know what the outcome of that discussion was, but it did occur to me that the simplest fix would be to multiply the divisors before doing the division. Here is code for that (src/data.c)... DEFUN ("/", Fquo, Squo, 2, MANY, 0, doc: /* Return first argument divided by all the remaining arguments. The arguments must be numbers or markers. usage: (/ DIVIDEND DIVISOR &rest DIVISORS) */) (nargs, args) int nargs; Lisp_Object *args; { if (nargs == 2) { return arith_driver (Adiv, nargs, args); } else { Lisp_Object divArgs[2]; divArgs[0] = args[0]; divArgs[1] = arith_driver (Amult, nargs-1, args+1); return arith_driver (Adiv, 2, divArgs); } } I've left nargs==2 as a special case for efficiency, because it wont change the existing behavior for 2 arguments, and because 2 arguments is by far the most common, and perhaps only, usage I see in the cvs *.el files. -- Peter Whaite (http://whaite.ca)