Use parens again if negative is factored out. (#455) #546
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR address issue #455, which causes the display for some reduced formulas be incorrect (parens are missing). The expression evaluates properly, but doesn't print properly. This is due to a setting that was trying to prevent
(-2)x
from showing as-(2*x)
when it is reduced.The reduction works by pulling negatives out and cancelling when possible, so
-5/(-2*x)
becomes-(5/(2*x))
, then-(5/(-(2*x))), then
-(-(5/(2x))and finally
5/(2x). But at the
(-2x)to
-(2x)reduction, the parens are suppressed (so it would print as
-2x, and the further reduction didn't change that, so you got
5/2xinstead of
5/(2*x)`. This PR removes the no-paren marker when the negation is moved further out, allowing the parens to be included again.