Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Reverse Polish notation
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Explanation == In reverse Polish notation, the [[operation (mathematics)|operator]]s follow their [[operand]]s. For example, to add 3 and 4 together, the expression is {{nowrap|3 4 +}} rather than {{nowrap|3 + 4}}. The conventional notation expression {{nowrap|3 β 4 + 5}} becomes {{nowrap|3 (enter) 4 β 5 +}} in reverse Polish notation: 4 is first subtracted from 3, then 5 is added to it. The concept of a ''[[stack (data structure)|stack]]'', a last-in/first-out construct, is integral to the left-to-right evaluation of RPN. In the example {{nowrap|3 4 β}}, first the 3 is put onto the stack, then the 4; the 4 is now on top and the 3 below it. The subtraction operator removes the top two items from the stack, performs {{nowrap|3 β 4}}, and puts the result of β1 onto the stack. The common terminology is that added items are ''pushed'' on the stack and removed items are ''popped''. The advantage of reverse Polish notation is that it removes the need for order of operations and parentheses that are required by [[infix notation]] and can be evaluated linearly, left-to-right. For example, the infix expression {{nowrap|(3 + 4) Γ (5 + 6)}} becomes {{nowrap|3 4 + 5 6 + Γ}} in reverse Polish notation.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)