emacs-devel
[Top][All Lists]

## Re: Calc: `*' binds more strongly than `/'

 From: Luc Teirlinck Subject: Re: Calc: `*' binds more strongly than `/' Date: Thu, 26 Apr 2007 13:32:36 -0500 (CDT)

```Stefan Monnier wrote:

> For what it's worth, Mathematica (one of the few other programs with the
> "implicit multiplication" operator) gives implicit and explicit
> multiplication and division equal precedence: a b/c d puts d in the
> numerator, as does a*b/c*d.

Hmm... that does come as unintuitive to me.

No.  Because b/c can be interpreted as an individual rational number,
rather than the result of an operation (division).  This is especially
true when you are using software that implements rational numbers.
This is actually one of the main reasons that / usually has precedence
over *: a*b/c*d can be considered as `a' times the rational number
`b/c' times `d'; / can also be considered as an operation and a,b,c,d
as four distinct numbers.  If you give / higher precedence as *, you
do not have to worry about which interpretation is "correct", since it
does not make any difference.

2/3 * 5/7 = 10/21, in either interpretation _assuming_ / has higher
precedence than *.

Of course, provoking discussions like this is one of the many reasons
why the Devil invented infix notation.  If you have to use it, then
the best way to defeat his brilliant but evil scheme is to always
write explicitly (a*b)/(b*c) or a*(b/c)*d, to leave no doubt whatsoever.

Sincerely,

Luc.

```