From unknown Thu Aug 14 22:14:36 2025 X-Loop: don@donarmstrong.com Subject: bug#923: In CVS Emacs, calc-eval gives multiplication higher precidence than division Reply-To: Stefan Monnier , 923@debbugs.gnu.org Resent-From: Stefan Monnier Resent-To: bug-submit-list@lists.donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Sun, 07 Sep 2008 21:25:05 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 923 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Received: via spool by submit@emacsbugs.donarmstrong.com id=B.122082214615131 (code B ref -1); Sun, 07 Sep 2008 21:25:05 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-5.8 required=4.0 tests=AWL,BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at submit) by emacsbugs.donarmstrong.com; 7 Sep 2008 21:15:46 +0000 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m87LFgD3015125 for ; Sun, 7 Sep 2008 14:15:43 -0700 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KcRbh-0006wa-TH for bug-gnu-emacs@gnu.org; Sun, 07 Sep 2008 17:15:41 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KcRbg-0006tP-Gu for bug-gnu-emacs@gnu.org; Sun, 07 Sep 2008 17:15:41 -0400 Received: from [199.232.76.173] (port=59565 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KcRbg-0006sw-8G; Sun, 07 Sep 2008 17:15:40 -0400 Received: from ironport2-out.pppoe.ca ([206.248.154.182]:24896 helo=ironport2-out.teksavvy.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KcRbf-0008E9-W0; Sun, 07 Sep 2008 17:15:40 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiQFAGjhw0hFxIqP/2dsb2JhbACBZbAVgWaBBw X-IronPort-AV: E=Sophos;i="4.32,353,1217822400"; d="scan'208";a="26488125" Received: from 69-196-138-143.dsl.teksavvy.com (HELO ceviche.home) ([69.196.138.143]) by ironport2-out.teksavvy.com with ESMTP; 07 Sep 2008 17:15:39 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 94C4FB4062; Sun, 7 Sep 2008 17:15:38 -0400 (EDT) From: Stefan Monnier To: jay.p.belanger@gmail.com Cc: bug-gnu-emacs@gnu.org, Francis Litterio , emacs-devel@gnu.org Message-ID: References: <878wu3j4k2.fsf@gmail.com> <873akbitie.fsf@gmail.com> Date: Sun, 07 Sep 2008 17:15:38 -0400 In-Reply-To: <873akbitie.fsf@gmail.com> (Jay Belanger's message of "Sun, 07 Sep 2008 15:35:37 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. >>> That's not a bug. While many systems give division a higher precendence >>> than multiplication, that isn't a universal rule. >> Actually, I don't know of any system that gives higher precedence to >> division. > According to Wikipedia: > An expression like 1/2x is interpreted as 1/(2x) by TI-82, but as > (1/2)x by TI-83. While the first interpretation may be expected by > some users, only the latter is in agreement with the standard rules > stated above. That could be due to a higher precedence, but could also be due to an equal precedence together with left-associativity. Given that (a*b)/c is often mathematically equal to a*(b/c), the difference is generally hard to see, unless rounding comes into play. All textbooks and language references I know use the "equal precedence and left associativity" rule rather than giving higher precedence to the division. >> The general rule that (AFAIK) all programming languages >> follow (other than those that don't use infix-with-precedence, such as >> Lisp and Smalltalk) is that * and / have the same precedence (and are >> left associative). > That behavior is available, but you have to ask for it by setting > `calc-multiplication-has-precedence' to nil. I know. But we're talking about the default behavior. Stefan