-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Bug on calculating % #163
Comments
So, I took a stab at trying to fix it and I noticed that the regex in the shouldProcess method of the percentage.php file doesn't consider the input decimal separator picked by the user. To test my hypothesis I updated the regex to consider the , as the decimal separator and it worked. So I went to to implementing the following changes: class Percentage extends CalculateAnything implements CalculatorInterface
... That seemed to have fixed the issue with the input, but the output still shows with the '.'. I think that's because the call to the cleanUp method. I can take a look at that too and submit a PR with the fixes. Would you be so kind as to tell me if I'm heading the right direction? Much appreciated |
So I noticed that change the output format fix the last issue I had. I also noticed that the other two ways to calculate % are broken ("30,5% of 100" and "10,5 % 100"). I will take a look at those two as well |
Ok, so adding the same regex cleanup treatment on percentageOf() seemed to have fixed the issue: private function percentageOf()
|
Describe the bug
Little background, I'm located in Brazil and the decimal separator here is the comma (,). While I'm trying to do some math with % I think I've encountered a bug. I have Alfred's calculator set to use comma as decimal separator as well as the Calculate Anything workflow.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
There should be the result of the calculations which should be 11,025
Debug Output
[12:40:44.428 AM] Logging Started...
[12:40:46.228 AM] Calculate Anything[Script Filter] Queuing argument '0,5+5%'
[12:40:46.295 AM] Calculate Anything[Script Filter] Script with argv '(null)' finished
[12:40:46.300 AM] Calculate Anything[Script Filter] {"items":[]}
System information:
Additional context
With comma as the decimal separator, if I try "10.5+5%" I get "110.25". So my only workaround is to set period as the decimal separate value.
The text was updated successfully, but these errors were encountered: