lcn2 / calc

C-style arbitrary precision calculator
http://www.isthe.com/chongo/tech/comp/calc/index.html
Other
357 stars 51 forks source link

Bug: XXX-change-this-part-XXX #117

Closed Andonome closed 1 year ago

Andonome commented 1 year ago

Calc bug report template version: 1.3 2022-11-27

Describe the bug

12/2*(3+3)

The result is 36.

Execution environment (please complete the following information):

Void Linux C-style arbitrary precision calculator w/custom functions (version 2.14.3.5)

Calc mods

None.

lcn2 commented 1 year ago

As noted in help unexpected:

$ calc
C-style arbitrary precision calculator (version 2.15.0.1)
Calc is open software. For license details type:  help copyright
[Type "exit" to exit, or "help" for help.]

; help unexpected

In particular: calc always evaluates terms from left to right.

12/2 ==> 6 6(3+3) ==> 66 ==> 36

Calc works as documented and by design.

Andonome commented 1 year ago

Thanks for the detailed reply. I was trying to give an example of the distributive law - 2(3+3) - but corrected the example quite badly when I saw it thinking of x(1 + 3) as a function with x.