1
$\begingroup$

Excuse me for the newbish question in advance but how should I make sure I don't make a mistake converting from RPN to infix notation when I don't know if some of the numbers aren't two-digit ones or when I do that some are but I don't know which ones? For example, how do I know if I should evaluate $112+$ to $11+2$ or $1+12$? Or such thing is impossible to evaluate when I don't know where the enters were put in?

$\endgroup$
3
$\begingroup$

You have to know where the breaks are (where the user pressed enter). In RPN, you put one number on the stack, put a second number in the next spot on the stack, and then do an operation on those two numbers. If you don't know the contents of each position in the stack (i.e., you don't know if 112 is 11 in one position and 2 in the other or 1 in one position and 12 in the other) then you can't evaluate it.

$\endgroup$
1
$\begingroup$

HP RPN calculators had (have?) an ENTER key for that reason. See this image.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.