Home

Rpn

Rpn, short for Reverse Polish Notation, also known as postfix notation, is a mathematical notation in which every operator follows all of its operands. In RPN expressions, the order of evaluation is unambiguous and no parentheses are needed.

Evaluation of RPN uses a stack. Read tokens from left to right: when you encounter a number,

Example: the expression "3 4 +" evaluates to 7. A more complex example, "5 1 2 + 4 *

RPN is commonly used in calculators and in stack-based programming languages. Hewlett-Packard’s scientific calculators popularized RPN

Advantages of RPN include elimination of parentheses and straightforward, efficient parsing on stack-based hardware. Its primary

See also Polish notation; postfix notation; stack machine.

push
it
onto
the
stack;
when
you
encounter
an
operator,
pop
the
appropriate
number
of
operands,
apply
the
operator,
and
push
the
result
back
on
the
stack.
At
the
end,
the
stack
contains
the
value
of
the
expression.
+
3
-",
evaluates
to
14.
The
steps
involve
pushing
numbers,
computing
subexpressions
with
operators,
and
reducing
to
a
final
result.
in
the
late
20th
century,
and
postfix
notation
is
also
used
in
languages
such
as
PostScript
and
Forth,
which
execute
expressions
via
a
stack
machine
rather
than
a
conventional
infix
parser.
limitations
are
reduced
readability
for
humans
accustomed
to
infix
notation
and
the
need
for
additional
transformation
when
converting
between
infix
expressions
and
RPN,
typically
using
algorithms
like
the
shunting-yard
method.