microsoft / microsoft/calculator
Inaccurate results for trigonometric functions with exact results
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 below examples of the trigonometric functions show a correct result at first. However, subtracting that result from itself results in a non-zero value, which shows that the results are represented as incorrect approximations internally, when it should be an exact result.
In DEG mode:
arcsin(1) - 90 != 0
sin(30) - 0.5 != 0
In RAD mode:
sin(π/2) - 1 != 0
but interestingly: cos(±π) + 1 == 0
This is a new issue spawned from the similar issue #222.
Steps To Reproduce
- Try the above calculations in scientific mode
Expected behavior
Exact internal representation and result 0 for above calculations.
Device and Application Information (please complete the following information):
- OS Build: 10 0 17763 0
- Architecture: X64
- Application Version: 10.1812.10048.0
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
Reproduce the listed calculations in scientific mode, covering both DEG and RAD modes, and compare the exact-result cases with the cosine case that already succeeds. Trace the trigonometric calculation path and identify how results are represented internally; done means the listed expressions evaluate to exact zero as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100