loading...

Discussion on: Daily Challenge #10 - Calculator

Collapse
jacoby profile image
Dave Jacoby

For context (and an example I'm hitting in my testing), 4 - 6 - 2. By PEMDAS, they're of equal order, but it really depends on if you want (4 - 6) - 2 == -4 or 4 - (6 - 2) == 0.

With RPN, it's always number number operator, and variations on that are how we get precedence.

4 6 2 - - has 6 2 - in number number operator form and thus becomes 4, simplifying to 4 4 - and then 0.

4 6 - 2 - would get you the 4 6 - first, giving -2, then -2 2 -, which is -4`

Not that I do my regular math like this...