unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Christian Schlauer <cs-muelleimer-rubbish.bin@arcor.de>
To: emacs-devel@gnu.org
Subject: Re: Calc: `*' binds more strongly than `/'
Date: Wed, 25 Apr 2007 21:56:51 +0200	[thread overview]
Message-ID: <f0obnu$gkh$2@sea.gmane.org> (raw)
In-Reply-To: 87ejmbdr1x.fsf@truman.edu

Jay Belanger <belanger@truman.edu> writes:

> storm@cua.dk (Kim F. Storm) writes:
> ...
>> I seem to be the only one who have spoken in favour of the current
>> precedence rule, but I'm only a casual user of calc, so my opinion
>> shouldn't matter here!
>
> You must have missed a few messages; you are by no means the only one
> in favor of the current rule.

I checked the thread and Randal L. Schwartz, Daniel Brockman and Kim
F. Storm backed up the current behaviour. Carsten Dominik likes the
current behaviour, too.

Stefan Monnier, Miles Bader, Jason Rumney and me "prefer" a change of
the current behaviour.

>> Besides, I usually add () to mixtures of / and * anyway (for clarity
>> and/or to dictate a specific evaluation order to get maximum precision
>> in the result).
>
> Well, I think that's the proper way of doing it; even though there are
> rules for interpreting expressions like a*b/c*d, that doesn't mean
> writing the expression that way is a good thing to do -- it's just bad
> form.  I don't think there is any difference between Calc's current
> precedence rule and the more standard one for properly written
> expressions.

I did some more `research', and a*b/c*d is not bad form, and it is a
properly written expression, see Wikipedia. Let me cite from
<http://en.wikipedia.org/wiki/Order_of_operations#Examples_from_arithmetic>:

,----
| 3. Evaluate multiplications and divisions, starting from the left:
| 
| 8/2*3 = [8/2]*3 = [4*3] = 12
`----

Further down on the same page:

"Since multiplication and division are of the same rank, [...]"

and further on (emphasis added by me):

,----
| Warning: Multiplication and division are of *equal precedence*, and
| addition and subtraction are of *equal precedence*. Using any of the
| above rules in the order addition first, subtraction afterward would
| give the wrong answer to
| 
| 10 - 3 + 2
| 
| The correct answer is 9, which is best understood by thinking of the
| problem as the sum of positive ten, negative three, and positive
| two.
| 
| It is usual, wherever you need to calculate operations of equal
| precedence to work *from left to right*. The following rules of
| thumb are useful:
| 
| First: perfom any calculations inside parentheses (brackets)
| 
| Second: Next perform all multiplication and division, working from
| *left to right*
| 
| Third: Lastly perform all addition and subtraction, working from
| *left to right*
`----

So besides Excel, Gnumeric, MATLAB, all pocket calculators, Wikipedia
agrees with me, too.

Calc's current behaviour is simply wrong, I'd say.

Regards,

Christian

P.S.: I have not edited the Wikipedia article.

  reply	other threads:[~2007-04-25 19:56 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-14 11:57 Calc: `*' binds more strongly than `/' Christian Schlauer
2007-04-14 15:09 ` Jay Belanger
2007-04-15 19:21   ` Chong Yidong
2007-04-15 20:05     ` Stefan Monnier
2007-04-17 12:47       ` Randal L. Schwartz
2007-04-17 18:03         ` Stefan Monnier
2007-04-18  8:44           ` Kim F. Storm
2007-04-18 19:27             ` Stefan Monnier
2007-04-18 20:02               ` Davis Herring
2007-04-18 20:16                 ` David Kastrup
2007-04-18 21:43                   ` Davis Herring
2007-04-19 16:10                 ` Stefan Monnier
2007-04-20 11:13                   ` Randal L. Schwartz
2007-04-20 13:40                     ` Stefan Monnier
2007-04-20 14:07                       ` Jay Belanger
2007-04-22  1:31                         ` Miles Bader
2007-04-22 10:19                           ` Christian Schlauer
2007-04-22 10:23                         ` Christian Schlauer
2007-04-22 19:47                           ` Jay Belanger
2007-04-23 10:46                           ` Jason Rumney
2007-04-23 13:03                             ` Kim F. Storm
2007-04-23 15:54                               ` Jay Belanger
2007-04-25 19:56                                 ` Christian Schlauer [this message]
2007-04-25 20:54                                   ` Jay Belanger
2007-04-26  3:35                                     ` Stefan Monnier
2007-04-26  4:06                                       ` Jay Belanger
2007-04-26 14:11                                         ` Stefan Monnier
2007-04-26 21:07                                           ` Christian Schlauer
2007-04-26 15:07                                         ` Davis Herring
2007-04-26 16:01                                           ` Stefan Monnier
2007-04-26 18:32                                             ` Luc Teirlinck
2007-04-26 21:29                                               ` Christian Schlauer
2007-04-26 23:17                                                 ` Luc Teirlinck
2007-04-26 21:07                                     ` Christian Schlauer
2007-04-27  1:27                                       ` Jay Belanger
2007-04-26 17:47                                   ` Davis Herring
2007-06-20 15:23                         ` Jay Belanger
2007-06-20 16:02                           ` Kim F. Storm
2007-06-20 17:13                             ` Jay Belanger
2007-06-20 17:29                             ` Luc Teirlinck
2007-06-20 17:54                               ` Jay Belanger
2007-06-20 19:14                                 ` Kim F. Storm
2007-06-20 19:28                                 ` Luc Teirlinck
2007-06-20 20:18                                   ` Jay Belanger
2007-04-17 18:54         ` Jay Belanger
2007-04-18 21:55           ` Christian Schlauer
2007-04-19  2:58             ` Daniel Brockman
2007-04-22 10:27               ` Christian Schlauer
2007-04-26 16:00                 ` Daniel Brockman
2007-04-19 15:16           ` Drew Adams
2007-04-19 17:05             ` David Kastrup
2007-04-19 17:18               ` Drew Adams
2007-04-19 17:33                 ` David Kastrup
2007-04-16 15:38     ` Richard Stallman
2007-04-17 12:47 ` Randal L. Schwartz
2007-04-18 21:29   ` Christian Schlauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='f0obnu$gkh$2@sea.gmane.org' \
    --to=cs-muelleimer-rubbish.bin@arcor.de \
    --cc=cs-usenet@arcor.de \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).