0

When I try to convert infix expression to postfix expression, 3*(3+6/2)

it will be converted to like this. 3362/+*

My problem is this, how can I handle if there is negative sign in front of parantheses? Like 3*-(3+6/2) or 3*(-(3+6/2))

When I try to convert these to postfix expressions, it would be like 3*362/+- and 3362/+-*, but none of these expressions are valid: I cannot calculate these expressions in common way which we use to calculate postfix expressions.

So is there any way to handle these?

  • 1
    Does [this post](https://stackoverflow.com/a/17132657/16466946) address your problem? – kikon Mar 24 '23 at 00:19
  • 1
    Or perhaps [this post](https://stackoverflow.com/q/20246787/56778) – Jim Mischel Mar 24 '23 at 05:39
  • Does this answer your question? [handling unary minus for shunting-yard algorithm](https://stackoverflow.com/questions/20246787/handling-unary-minus-for-shunting-yard-algorithm) – MvG Mar 24 '23 at 10:39

0 Answers0