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

Problems in BasicArithmeticExpression and unary operators #1

Closed
artemlos opened this issue Dec 31, 2014 · 1 comment
Closed

Problems in BasicArithmeticExpression and unary operators #1

artemlos opened this issue Dec 31, 2014 · 1 comment
Assignees
Labels

Comments

@artemlos
Copy link
Member

This issue was reported by @ljubomirb.

An error will be thrown if the following expression is parsed:

-sin(5)

The error occurs in BasicArithmeticExpression method, since all operators are binary and require two values.

Workaround
This can be fixed, but in meantime, please use the workaround suggested for Factorial notation. It's described here: http://blog.artemlos.net/posts/factorial-notation-in-mathos-parser-1/

@artemlos artemlos added the bug label Dec 31, 2014
@artemlos artemlos self-assigned this Dec 31, 2014
@artemlos artemlos changed the title Problems in BasicArithmeticExpression and unary signs Problems in BasicArithmeticExpression and unary operators Dec 31, 2014
@artemlos artemlos closed this as completed Jan 3, 2015
@artemlos
Copy link
Member Author

artemlos commented Jan 3, 2015

This was fixed with a replacement of

return decimal.Parse((op == "+" ? "" : "-") + tokens[1], CultureInfo);

with

return decimal.Parse((op == "+" ? "" :  (tokens[1].Substring(0,1) == "-" ? "" : "-" ) ) + tokens[1], CultureInfo);

This does solve this issue, but we need to add support for unary operators also.

@artemlos artemlos reopened this Jan 3, 2015
@artemlos artemlos closed this as completed Jan 3, 2015
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