0

how do i deal with negation? i mean for example:

  • -(3 + 2) * -(9 / -3)
  • -((((-4 + 5))))

when I convert it to Postfix form the result is:

  • 3 2 + * - 9 / 3 - -
  • 4 - 5 + -

but here when I evaluate each one it will give errors because of the minus, how do I solve this?

  • ... Implement it. I guess you don't know the algorithm to do it, in that case use [tag:algorithm]. – user202729 Apr 04 '18 at 15:29
  • [Possible duplicate](https://stackoverflow.com/questions/20246787/handling-unary-minus-for-shunting-yard-algorithm) and [possible duplicate](https://stackoverflow.com/questions/17254080/infix-to-postfix-algorithm-that-takes-care-of-unary-operators). – user202729 Apr 04 '18 at 15:30
  • You need to distinguish `-` as negation and `-` as substraction. These are two different operators. – lexicore Apr 04 '18 at 15:31

0 Answers0