7 ms·
There is something wrong with the order of operations. When I type 2+2*2-6 i get -6 which should be 0.
by brospars 4y ago
There is something wrong with the order of operations. When I type 2+2*2-6 i get -6 which should be 0.
- bdwjn 4y agoOh there's more: 9 - 3 ^ 2 = 0 9 -3 ^ 2 = 18 ??? pi = 3.1415926536 2 pi = 5.1415926536 ??? sin(3.1415926536 radians) = -0 sin(pi radians) = Incompatible units ???
- wizofaus 4y agoSeems to assume + if an arithmetic operator is missing?
- tonyonodi 4y agoThis is correct, the idea is that you can type things like "6 foot 3 inches" and have it evaluate as an addition. But the example shown above is definitely a problem, I'll try to think of a work around.
- wizofaus 4y agoI'd think that rule only makes sense after a symbol representing a unit (including potentially 6'3"). Certainly <number> <named constant> should logically assume multiplication.
- unsafecast 4y agoIt looks like APL order? Right-to-left.
- JackFr 4y agoNo. It’s not right to left. It’s just weird: 3 ^ 1 * 2 6 3 ^ 1 / 2 1.73205 3 ^ 1 + 2 5 3 ^ 1 - 2 1
- unsafecast 4y agoHuh.
- sneak 4y agoI would think this might be the first unit test one would write for a calculator program.
- deleted 4y ago[deleted]
- simonz05 4y agoYep, this should be evaluated as `(- (+ 2 (* 2 2)) 6)`