0

Infix expression : 2+³√-(4+4) Evaluation of which results in 0.

However, when converted into postfix and evaluated, it gets confusing.

Postfix expression : 244+-³√+

It gets confusing at the negation operator, to evaluate it correctly, we should only take one operand and negate it, however the negation operator(subtraction) can also take two operands and just subtract, i can't figure out a way to tell the code correctly whether to pick just one operand or two, it's for a Coding project but I feel like its more of a maths question.

  • 2
    You'll either need different expressions for negation and subtraction, require an explicit $0a-$ to negate, or use $ab-+$ for subtraction. Infix only gets away with the implied $0$ because the missing operand signals it. – eyeballfrog Jul 13 '22 at 13:50
  • Thanks for helping me out, I'm now just substituting 0 wherever an operand is missing, and it's working great for me. :) – Amit_dash_234 Jul 14 '22 at 09:06

0 Answers0