4 ms·
Emacs Calc (not unlike much of the rest of Emacs) is a little ... special. By default, it calculates 4/2*2 as 1, because multiplication has a higher precedence
by CyberShadow 5y ago
Emacs Calc (not unlike much of the rest of Emacs) is a little ... special. By default, it calculates 4/2*2 as 1, because multiplication has a higher precedence than division.
https://orgmode.org/manual/Formula-syntax-for-Calc.html https://orgmode.org/manual/Formula-syntax-for-Calc.html
- bufferoverflow 5y ago> because multiplication has a higher precedence than division Wow. That's actually quite bad.
- bee_rider 5y agoI think some people learned P-E-MD-AS as if MD and AS didn't have the same precedence. I mean, it's a convention anyway, so they aren't really "wrong" insomuch as just being unusual. But it does seem like an odd thing to disagree about. I think there's also some confusion about whether the / symbol is actually being used as a single line equivalent to a fraction, which might introduce some ambiguity? I forget. The number of ways that people can misunderstand things is infinite, so it can be hard to keep track. Anyway, parentheses are cheap and misunderstandings, even when the other party ought to take the blame, can be expensive, so I've taken up the habit of being generous with the things.
- deleted 5y ago[deleted]
- gnuvince 5y agoI've used Emacs Calc for >5 years and never knew about this, because I always do calculations in RPN.
- michaelmrose 5y agoYou could open an issue. Seems like a reasonable idea to fix that.
- matsemann 5y agoMaking it the opposite is wrong as well, though (PEMDAS or whatever the acronym americans learn isn't the sole truth). Just use parenthesis.
- CyberShadow 5y agoIt's by design. The option calc-multiplication-has-precedence controls this behavior.