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

Problem with brackets #14

Closed
samvid1992 opened this issue Aug 12, 2014 · 3 comments
Closed

Problem with brackets #14

samvid1992 opened this issue Aug 12, 2014 · 3 comments

Comments

@samvid1992
Copy link

There are two issue that i found and i dont know how to fix it. Issue is if you have string like this "2_3(5_3)", the answer should be 90 but the program gives 45. Any suggest about how shall i fix this??

Also expression like "2_3_(5*3)" should give answer 90 but instead it gives 9E+1.

@uklimaschewski
Copy link
Collaborator

2_3(5_3) should throw an error, because it is not a valid expression.
This is a bug, I will have a look into it.

2_3_(5*3) is correctly 9E+1 (which is a different notation for 90).
The result in scientific notation comes from the Java BigDecimal class.
To be exact, from the toString() method of BigDecimal.
If you want to have 90 as a result, you should use the toPlainString() method of BigDecimal.

@samvid1992
Copy link
Author

thanks. i will try using toPlainString() method of BigDecimal.

your program is really cool. I wanted to learn math expression parsing for my college project and your program is really easy to understand and works perfectly. Thanks once again for creating it.

@uklimaschewski
Copy link
Collaborator

I checked in a bugfix. The expression 2*3(5*3) now will throw an ExpressionExeption Missing operator at character position 4.

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

No branches or pull requests

2 participants