The calculation oder is wrong
Opened this issue · 3 comments
Deleted user commented
sulami commented
pRot0ta1p ***@***.***> writes:
Like this:
![2](https://user-images.githubusercontent.com/37837882/122078442-2dac8d80-ce2f-11eb-9791-190f46ec27ac.PNG)
Multiplication and division have the same calculation priotiry, so it
should gives 16 even without explicit parentheses, but it seems
multiplications are calculated first then the division...
I had a look at this and it seems to an Emacs calc oddity. Apparently
selecting (or defining) a different "language mode"[0] can alter
operator precedence rules, but that also comes with other changes, such
as the kinds of braces used for vectors and sets. Ideally I'd like to
keep the current behaviour except for the weird operator precedence,
which likely means defining our own language mode. I'm not sure when
I'll have the time to get to that, so if you're feeling courageous feel
free to venture into that territory (or suggest alternative solutions, I
might well be on the wrong path).
[0]: https://www.gnu.org/software/emacs/manual/html_node/calc/Language-Modes.html#Language-Modes
Deleted user commented
@sulami I found the solution (setq calc-multiplication-has-precedence nil)
,
calc-mode gives ‘/’ lower precedence than ‘*’ . Wired default... but I guess this can be closed then.
sulami commented
pRot0ta1p ***@***.***> writes:
@sulami I found the solution `(setq calc-multiplication-has-precedence nil)`,
[calc-mode gives ‘/’ lower precedence than ‘*’ ](https://www.gnu.org/software/emacs/manual/html_node/calc/Algebraic-Tutorial.html). Wired default... but I guess this can be closed then.
Ah, great find! I'll add a note to the readme, it's not a LCM-specific
problem but still a potential gotcha.