microsoft / microsoft/calculator
Incorrect Exponent Calculation
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 31.1k
- Forks
- 5.8k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
Calculating 2^2^2^2 produces 256 as the answer.
The correct answer should be 65536.
Order of operations dictate that the highest exponent should be calculated first as if there were parenthesis like (2^(2^(2^2))).
Steps To Reproduce
- Go to calculator
- enter 2^2^2^2
- See incorrect calculation of 256
Expected behavior
This should be calculated properly as 65536
Screenshots
Device and Application Information
- OS Build: 10.0.22631.0
- Architecture: X64
- Application Version: 11.2405.2.0
- Region: en-US
- Dev Version Installed: False
Additional context
This problem exists with all tested numbers (not just 2). The error is in calculating the exponents from left to right instead of right to left.
Requested Assignment
I'm just reporting this problem. I don't want to fix it.
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 by reproducing 2^2^2^2 in the calculator and trace how chained exponent operators are evaluated. The fix is done when exponentiation is evaluated from right to left, producing 65536, and equivalent cases with other numbers behave correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100