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

-3^(1*2) wrong result #64

Closed
ghost opened this issue Jan 10, 2023 · 6 comments
Closed

-3^(1*2) wrong result #64

ghost opened this issue Jan 10, 2023 · 6 comments
Labels

Comments

@ghost
Copy link

ghost commented Jan 10, 2023

It returns -6. It should return -9.
Also -3^(1+1) returns -4. It should return -9. But 0-3^(1+1) return correct answers. (The same for the first example)

@github-actions
Copy link

🎉 This issue has been resolved in version 2.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@bugwheels94
Copy link
Owner

-3^(1*2) should be returning 9 and i have fixed it. Thanks for informing!

@ghost
Copy link
Author

ghost commented Jan 23, 2023

I think the problem remains (in version 2.0.1):
-3^2 = -9 [right]
-3^(1+1) = -4 [wrong]
-3^(1*2) = -6 [wrong]

@bugwheels94
Copy link
Owner

working fine here: https://jsbin.com/romatuc/edit?html,output

Make sure that you actually are on 2.0.1

@ghost
Copy link
Author

ghost commented Jan 25, 2023

In school we learn (-3)^2=9 and -3^2=-(3^2)=-9. I understand that you want the unary operator '-' to have a bigger priority than operator '^', but it is not something that we find frequently. If you keep this convention, look the problem: All of us know that a-b=a+(-b), so 9-3^2=9+(-3^2) and although the two previous expressions are equal, your script evaluates the first expression to 0 and the second to 18. Check it.
(I am a mathematician with a master in information systems)

@bugwheels94
Copy link
Owner

bugwheels94 commented Jan 25, 2023

I am no mathematician ^_^ but I agree with you. May you try now at version 2.0.2. Actually, the second last message with -4, -6 got me confused a bit in understading your point. This change is passing all of the tests but I hope it does not break anything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant