Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculator no longer handles scientific notation properly #25656

Closed
Tracked by #28182
taipingli opened this issue Apr 22, 2023 · 7 comments
Closed
Tracked by #28182

Calculator no longer handles scientific notation properly #25656

taipingli opened this issue Apr 22, 2023 · 7 comments
Labels
Issue-Bug Something isn't working Product-PowerToys Run Improved app launch PT Run (Win+R) Window Resolution-Fix Committed Fix is checked in, but it might be 3-4 weeks until a release.

Comments

@taipingli
Copy link

Microsoft PowerToys version

0.69.1

Installation method

GitHub

Running as admin

No

Area(s) with issue?

PowerToys Run

Steps to reproduce

Entering into the calculator through PowerToys Run any of the following:
=1e3
=10e3 + 5
=1e-3

✔️ Expected Behavior

=1e3 = 1000
=10e3 + 5 = 10005
=1e-3 = 0.001

❌ Actual Behavior

=1e3 = Failed to calculate the input - Expression wrong or incomplete (did you forget some parentheses?)
=10e3 + 5 = Failed to calculate the input - Expression wrong or incomplete (did you forget some parentheses?)
=1e-3 = -0.2817181715

Other Software

No response

@taipingli taipingli added Issue-Bug Something isn't working Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams labels Apr 22, 2023
@taipingli
Copy link
Author

I think this issue may be caused by the changes in #24655? On another computer with 0.68.1, I see the expected behavior with Powertoys Run when entering anything with scientific notation in the form of XeY, where X and Y are both numbers.

@tillfalko
Copy link

It seems that e is now always parsed as the mathematical constant.
It should be possible to syntactically infer whether scientific notation or the constant is intended with e.
Alternatively scientific notation could be invoked with an upper case E, which is unused, and what most scientific calculators display anyways.

@Aaron-Junker Aaron-Junker added the Product-PowerToys Run Improved app launch PT Run (Win+R) Window label Aug 29, 2023
@viggyd
Copy link
Contributor

viggyd commented Sep 26, 2023

I agree with tillfalko, the scientific notation typically follows a <number>e<number> with no spaces between, which should be easy enough to check.

I'm thinking in the FixHumanMultiplicationExpressions, you can add a new function, maybe something like CheckScientificNotation, that replaces "(\d+)[eE]([-]*\d+)" with "$1 * 10^($2)". The replacement removes the e from the expression, preventing it from being used as a constant. It also supports either capital or lowercase e for use in scientific notation.

I can probably get something out by the end of the week if no one else is working on it

@Jay-o-Way
Copy link
Collaborator

Jay-o-Way commented Dec 27, 2023

Okay, so the problem is that there are three possible interpretations for numbers like 8e3, 12e-2 and so on. The "E" could be the constant, the denominator for the scientific notation, or the number can be hexadecimal. Without context, there really is no way to tell. This is a big issue that needs to be solved first. This is exactly why the Calculator app has modes: to set the context.

input const scientific HEXtoDEC
8e3 ≈ 65.2388... 8'000 227510
12e-2 ≈ 30.619... 0.0012 30010

Another example: 8B could be hexadecimal for 139, or in common use could also mean 8 Billion.

@Jay-o-Way Jay-o-Way added Status-Blocked We can't make progress due to a dependency or issue and removed Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams labels Dec 27, 2023
@Jay-o-Way

This comment was marked as off-topic.

@stefansjfw stefansjfw added Resolution-Fix Committed Fix is checked in, but it might be 3-4 weeks until a release. and removed Status-Blocked We can't make progress due to a dependency or issue Status-In progress This issue or work-item is under development labels Jan 3, 2024
@jaimecbernardo
Copy link
Collaborator

This has been worked on during the 0.77 Release sprint. Please update PowerToys to the latest release: https://github.com/microsoft/PowerToys/releases

@abegertler
Copy link

abegertler commented Jan 10, 2024

Oh my gosh, wonderful!!! : ))) thank you so much everyone : ) especially @viggyd

it works : ) 7E3 = 7000 : )

This has been worked on during the 0.77 Release sprint. Please update PowerToys to the latest release: https://github.com/microsoft/PowerToys/releases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug Something isn't working Product-PowerToys Run Improved app launch PT Run (Win+R) Window Resolution-Fix Committed Fix is checked in, but it might be 3-4 weeks until a release.
Projects
None yet
Development

No branches or pull requests

9 participants