3 ms·
RPN requires implementing a stack on silicon, which adds even more complexity and uncertainty. How deep can the stack go? What happens to your calculation when
by x3n0ph3n3 2y ago
RPN requires implementing a stack on silicon, which adds even more complexity and uncertainty. How deep can the stack go? What happens to your calculation when you exceed its capacity?
- Pinus 2y agoClassic HP calculators used a fixed stack of four registers. In practice, you can do quite complicated things before you blow that up. Especially if you understand how the mechanism works, and plan ahead a bit. Besides, infix-style calculators also seem to use a stack to handle operator precedence — if you squint a bit at the manual, you can usually see the shunting-yard algorithm at work behind the curtains. Actually, some really early HP:s (only desktops, though, like the 9100) used a three-level “stack”, which I put in quotes, because it relied on the user to shift the registers up and down as needed. But they cheated a bit and displayed all three registers, so that the user could see what was where.
- roelschroeven 2y ago> Besides, infix-style calculators also seem to use a stack to handle operator precedence True, but simple calculators, even ones a bit more advanced than the one in the article (e.g. with a sqrt and/or % key) don't handle operator precedence. I'm not sure it's even correct to call them infix calculators, for that reason. They simply work sequentially; no stack needed.
- kazinator 2y agoCompared to what? RPN allows for complex, nested expressions for which infix requires nested parentheses. Nesting requires a stack, the same way.