From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Lars Brinkhoff Newsgroups: gmane.emacs.devel Subject: Re: Strange division using mixed integers and floats Date: 28 Apr 2004 15:20:56 +0200 Organization: nocrew Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <85smeodyrr.fsf@junk.nocrew.org> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1083162157 32451 80.91.224.253 (28 Apr 2004 14:22:37 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 28 Apr 2004 14:22:37 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Wed Apr 28 16:22:16 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 1BIpx1-000487-00 for ; Wed, 28 Apr 2004 16:22:15 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BIpx1-000618-00 for ; Wed, 28 Apr 2004 16:22:15 +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 1BIp55-0007PA-5S for emacs-devel@quimby.gnus.org; Wed, 28 Apr 2004 09:26:31 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BIp0M-0006Fs-RH for emacs-devel@gnu.org; Wed, 28 Apr 2004 09:21:38 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BIozm-00065M-TL for emacs-devel@gnu.org; Wed, 28 Apr 2004 09:21:35 -0400 Original-Received: from [80.91.224.249] (helo=main.gmane.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BIozm-000656-Jk for emacs-devel@gnu.org; Wed, 28 Apr 2004 09:21:02 -0400 Original-Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1BIozl-0003I4-00 for ; Wed, 28 Apr 2004 15:21:01 +0200 Original-Received: from junk.nocrew.org ([213.242.147.30]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 28 Apr 2004 15:21:01 +0200 Original-Received: from lars by junk.nocrew.org with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 28 Apr 2004 15:21:01 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 35 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: junk.nocrew.org User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 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:22300 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:22300 David Kastrup writes: > Richard Stallman writes: > > But this behaviour is *highly* confusing: > > (/ 5 4 2.3) => 0.4347826086956522 > > Cf. (/ 5 4.0 2.3) => 0.5434782608695653 > > > > We could change the functions to convert the arguments to floating > > point at the start if any is floating point. Is there any reason > > not to do that? > > Efficiency? Lisp is not a statically typed language. We don't know > the type of the arguments until after they have been evaluated. We > would have to store all intermediate results away before being > allowed to do the first operation. Seems like it's only a matter of changing arith_driver to do if (FLOATP (val)) { if (code == Adiv) return float_arith_driver (0.0, 0, code, nargs, args); else return float_arith_driver ((double) accum, argnum, code, nargs, args); } or similar. Loss of efficiency should be small. > Also (/ 5 4 2.3) would no longer be equivalent to (/ (/ 5 4) 2.3). That's more significant, as it's a user-visible change. -- Lars Brinkhoff, Services for Unix, Linux, GCC, HTTP Brinkhoff Consulting http://www.brinkhoff.se/