microsoft / microsoft/calculator

Incorrect Exponent Calculation

Open
#2,201 4 comments 0 reactions 0 assignees View on GitHub

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

  1. Go to calculator
  2. enter 2^2^2^2
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.