microsoft / microsoft/calculator
Support Reverse Polish Notation (RPN)
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 31.1k
- Forks
- 5.8k
- PR merge metrics
- No merged PRs in 30d
Description
Problem Statement
Reverse Polish Notation / RPN / Postfix mode is an alternate calculator entry mode that is very powerful (leveraging a stack does this!) and should be simple enough to implement.
This behaviour can be seen in physical HP scientific calculators, or the calc mode in Emacs.

Evidence or User Insights
It's a simple addition with minimal overhead that would please some potential users that right now need to seek other solutions.
Goals
Users can toggle an RPN mode of entry
Low-Fidelity Concept
Simple psuedocode:
#! python3
# Or a function list, or something to check if input is "function" or "input"
functionMap = {
"+": lambda x, y: x + y,
# ....
"mod": lambda x, y: x % y
}
stack = []
while True:
userInput = getInput()
# If it's not a function, add it to the stack
if userInput not in functionMap.keys():
stack.append(userInput)
else:
# Evaluate the last two items on the stack.
# In real usage, the last stack item is often implicit, eg,
# 27 [enter] 3 /
# rather than
# 27 [enter] 3 [enter] /
b = stack.pop()
a = stack.pop()
stack.append(functionMap[userInput](a, b))
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with docs/NewFeatureProcess.md for the project's feature-pitch expectations, then review the RPN description and pseudocode in this issue. Done should mean users can toggle an RPN entry mode and use stack-based operands and operators as described; the issue does not name implementation files or tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100