4 ms·
I'm not sure about the 41C, but I have a 32SII and you don't need to process "from the inside out". When you encounter an open parenthesis, then you just push
by xelxebar 9y ago
I'm not sure about the 41C, but I have a 32SII and you don't need to process "from the inside out".
When you encounter an open parenthesis, then you just push the following number onto the stack, when you encounter a close parenthesis, you just perform the relevant arithmetic operation.
For the example
2 * (3 + 4)
we can do this
Input Stack
2 2
3 3,2
4 4,3,2
+ 7,2
* 14
- hota_mazi 9y agoIt works here because the expression is simple. You only have four variables on the stack (maybe more in later models that I'm not aware of) and for those, you are screwed if you just push things on the stack in reading order: 2 * (3 + (4 + (5 + (6 + 7)) The only way to process this is to determine the most nested expression and start there: 6 7 + 5 + 4 + 3 + 2 * ... you get the idea. Expand this expression with multiple deeply nested parens and the limitations of RPN become very obvious.
- ScottBurson 9y agoI'm pretty sure the more recent, higher-end RPN calculators have lots more than 4 stack slots. 4 is usually enough in practice anyway. Your example is artificial. Besides, are you sure your infix calculator will accept this deep a nesting of parentheses? The TI models that were contemporary with the early HPs certainly wouldn't!
- deleted 9y ago[deleted]