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

Correct parantheses for arithmetic unary minus #13

Closed
Zerseu opened this issue Sep 10, 2017 · 1 comment
Closed

Correct parantheses for arithmetic unary minus #13

Zerseu opened this issue Sep 10, 2017 · 1 comment
Assignees
Labels

Comments

@Zerseu
Copy link

Zerseu commented Sep 10, 2017

Please correct me if I'm wrong, but shouldn't double negation of x yield "-(-x)"?
Instead it returns "--x".

The following statement fails:
Assert.AreEqual(Expression.Negate(Expression.Negate(Expression.Parameter(typeof(double), "x"))).ToReadableString(), "-(-x)");

@SteveWilkes SteveWilkes self-assigned this Sep 11, 2017
@SteveWilkes
Copy link
Member

Hi!

The two look to produce the same result (see this fiddle) so I think it's just a question of coding style. The library generally minimises use of parentheses.

Thanks for the feedback :)

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

2 participants