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

[PowerToys Run] Which functions should the calculator support? #3431

Closed
pekspro opened this issue May 21, 2020 · 3 comments
Closed

[PowerToys Run] Which functions should the calculator support? #3431

pekspro opened this issue May 21, 2020 · 3 comments
Labels
Product-PowerToys Run Improved app launch PT Run (Win+R) Window

Comments

@pekspro
Copy link
Contributor

pekspro commented May 21, 2020

I was looking for some documentation of which functions the calculator in the launcher should support (great feature by the way). I did not find any, so I look into the source code and found this:

    private static readonly Regex RegValidExpressChar = new Regex(
                    @"^(" +
                    @"ceil|floor|exp|pi|e|max|min|det|abs|log|ln|sqrt|" +
                    @"sin|cos|tan|arcsin|arccos|arctan|" +
                    @"eigval|eigvec|eig|sum|polar|plot|round|sort|real|zeta|" +
                    @"bin2dec|hex2dec|oct2dec|" +
                    @"==|~=|&&|\|\||" +
                    @"[ei]|[0-9]|[\+\-\*\/\^\., ""]|[\(\)\|\!\[\]]" +
                    @")+$", RegexOptions.Compiled);

But several of these are not supported and some are getting unexpected results:

  • ln is not supported, but log is.
  • log(100) gives the result 4.6, not 2. Mages Engine is calculating with e as base, not 10 as I would expect behave like a human.
  • The trigonometric functions are using radians. I think degrees is more appropriate.
  • If you are writing sort(42), an array is returned but it looks strange in the UI.

I could do some PR’s about this if you want to, just needs to know what should be supported.

@pekspro pekspro changed the title Which functions should the calculator support? [PowerToys Run] Which functions should the calculator support? May 21, 2020
@Jay-o-Way
Copy link
Collaborator

The log and trigonometric functions actually depend on the (seemingly implied) base and preference. There should be an option to include/select these?? Also, when I try "sin(30°)", manually using degrees, there are no results, which is a bug if you ask me.

@pekspro
Copy link
Contributor Author

pekspro commented May 24, 2020

The calculator is using Mages to make the calculations, which have these bases as default.

I have seen #2265 that is suggestion to use the same engine as the calculator in Windows which I think is a good idea. Even if that is not possible now, it would be good to try to align the behavior.

@jyuwono jyuwono added the Product-PowerToys Run Improved app launch PT Run (Win+R) Window label May 28, 2020
@crutkas
Copy link
Member

crutkas commented Aug 27, 2020

Since we're based off Wox, the csystem currently uses MAGES
https://github.com/FlorianRappl/Mages/blob/master/doc/functions.md is their full list.

@crutkas crutkas closed this as completed Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Product-PowerToys Run Improved app launch PT Run (Win+R) Window
Projects
None yet
Development

No branches or pull requests

4 participants