microsoft / microsoft/calculator

associativity of the power (^) operator

Open
#2,004 1 comment 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

The power (^) operator is by convention* right-associative. But the Calculator does not seem to follow that.

Steps To Reproduce

  1. Go to Scientific View
  2. Input 2 ^ 3 ^ 2, Hit "="
  3. The result is 64. ((2^3)^2=64)

Expected behavior

Should be 512. (2^(3^2)=512)

Screenshots

image

Device and Application Information

  • OS Build: 10.0.19045.0
  • Architecture: X64
  • Application Version: 11.2210.0.0
  • Region: zh-CN
  • Dev Version Installed: False

Additional context

* See: https://en.wikipedia.org/wiki/Operator_associativity
and https://en.wikipedia.org/wiki/Exponentiation

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

Reproduce the expression in Scientific View using 2 ^ 3 ^ 2, then trace the calculator's expression evaluation to find where operator associativity is determined. Done means the expression evaluates to 512 rather than 64, with coverage for this chained-power case if the existing evaluation tests are located.

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.