-
-
Notifications
You must be signed in to change notification settings - Fork 6
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 doesn't calculate #9
Comments
Forgot to mention: Release is the latest from Flathub, 0.1.0 |
Thanks for opening this issue, I'll try to fix this in the next couple days. |
Same issue exists when built from source. I had to double take after doing some subtraction, because the result was far from being correct. I'd also get something random each time when trying to do addition. Also, this is a little OT, but numpad support would be greatly appreciated. :) |
This should be fixed by 046bec0, I'll await for feedback before closing this. |
Sorry for the late response. I work weekends, so I wasn't able to get back to this until now. Something still seems a little off. At first, addition gave me something wildly incorrect (8+8=66), but after plugging in more things, it seems to have corrected itself. I can't get it to reproduce an incorrect output. Algebraic expressions, however, do give the wrong output. This is actually supposed to be 30. |
Yeah, the calculator-rs dependency doesn't handle operator precedence without parenthesis, so it's AST is kind of wrong, if you want to make it work correctly and in an easy way just copy the implementation of the parser & evaluator from here: https://github.com/balajisivaraman/basic_calculator_rs/blob/master/src/main.rs it uses the nom parser library : https://github.com/rust-bakery/nom , famous for those kind of things, there is a book here: https://tfpk.github.io/nominomicon/introduction.html , cc @edfloreshz |
Thank you, I'll look into it as soon as possible. |
I have some fixes (there may be other bugs) in an open PR here: https://github.com/0byteme/calculator/pull/1/commits or on my main branch on my fork: https://github.com/l-const/calculator cc @edfloreshz . Also this line here does integer division: https://github.com/0byteme/calculator/blob/main/src/lib.rs#L151. e.g: 4 / 5 = 0 not 0.8 it calls this: https://doc.rust-lang.org/std/primitive.i64.html#impl-Div-for-i64 , not sure this is what we want but didn't check it much further. Actually, opened a separate issue for this one to question the impl: 0byteme/calculator#2, @uciharis that is integer division most probably. https://gist.github.com/rust-play/21f0af3fb853da359f3af66b1690bc60 |
calculator-rs doesn't seem to be actively developed or maintained. Perhaps it'd be better to use evalexpr instead. It's still being actively developed. |
Thanks, I've been busy with other projects but I'll try to make some time for calculator next weekend. |
Should be solved, we can reopen if we find issues again. |
did you check integer division @edfloreshz , i am not sure it is handling appropriately from this comment: ISibboI/evalexpr#125 (comment) they are using a programming evaluation context and not one for gui calculation one? what 4 / 5 outputs? Nevermind, it actually works fine. |
I think I don't have to explain further → A picture is worth a thousand words
The text was updated successfully, but these errors were encountered: