Reverse Polish notation
(employing RPN) from 1991 Reverse Polish notation (RPN), also known as reverse Łukasiewicz notation, Polish postfix notation or simply postfix notation, is a mathematical notation in which operators follow their operands (e.g. 3\ 4\ + ), in contrast to the more common infix notation (in which operators are placed between operands, e.g. 3 + 4 ), as well as prefix notation (in which operators precede their operands, e.g. +\ 3\ 4 ). The notation does not need any parentheses as long as each operator has a fixed number of operands. Here are some examples to illustrate the differences between the aforementioned types of notation: The term postfix notation describes the general scheme in mathematics and computer sciences, whereas the term reverse Polish notation typically refers specifically to the method used to enter calculations into hardware or software calculators, which often have additional side effects and implications depending on the actual implementation involving a stack. The description "Polish" refers to the nationality of logician Jan Łukasiewicz, who invented Polish notation in 1924. The first computer to use postfix notation, though it long remained essentially unknown outside of Germany, was Konrad Zuse's Z3 in 1941 as well as his Z4 in 1945.…
(employing RPN) from 1991 Reverse Polish notation (RPN), also known as reverse Łukasiewicz notation, Polish postfix notation or simply postfix notation, is a mathematical notation in which operators follow their operands (e.g. 3\ 4\ + ), in contrast to the more common infix notation (in which operators are placed between operands, e.g. 3 + 4 ), as well as prefix notation (in which operators precede their operands, e.g. +\ 3\ 4 ). The notation does not need any parentheses as long as each operator has a fixed number of operands. Here are some examples to illustrate the differences between the aforementioned types of notation: The term postfix notation describes the general scheme in mathematics and computer sciences, whereas the term reverse Polish notation typically refers specifically to the method used to enter calculations into hardware or software calculators, which often have additional side effects and implications depending on the actual implementation involving a stack. The description "Polish" refers to the nationality of logician Jan Łukasiewicz, who invented Polish notation in 1924. The first computer to use postfix notation, though it long remained essentially unknown outside of Germany, was Konrad Zuse's Z3 in 1941 as well as his Z4 in 1945. The reverse Polish scheme was again proposed in 1954 by Arthur Burks, Don Warren, and Jesse Wright and was independently reinvented by Friedrich L. Bauer and Edsger W. Dijkstra in the early 1960s to reduce computer memory access and use the stack to evaluate expressions. The algorithms and notation for this scheme were extended by the philosopher and computer scientist Charles L. Hamblin in the mid-1950s. During the 1970s and 1980s, Hewlett-Packard used RPN in all of their desktop and hand-held calculators, and has continued to use it in some models into the 2020s. In computer science, reverse Polish notation is used in stack-oriented programming languages such as Forth, dc, Factor, STOIC, PostScript, RPL, and Joy. The computation may be illustrated as such: \begin{align} \ & 3\ 4\ -\ 5\ + \\ =\ & (-1)\ 5\ + \\ =\ & 4 \end{align} The concept of a stack, a last-in/first-out construct, is integral to the left-to-right evaluation of RPN. In the example , 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 , and puts the result of −1 onto the stack. Common language in this context refers to items being pushed onto the stack when added and popped or removed from the stack when taken off. 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 becomes in reverse Polish notation. ==== Hewlett-Packard ==== Hewlett-Packard engineers designed the 9100A Desktop Calculator in 1968 with reverse Polish notation with only three stack levels with working registers X ("keyboard"), Y ("accumulate") and visible storage register Z ("temporary"), a reverse Polish notation variant later referred to as three-level RPN. This calculator popularized reverse Polish notation among the scientific and engineering communities. The HP-35, the world's first handheld scientific calculator, introduced the classical four-level RPN with its specific ruleset of the so-called operational (memory) stack (later also called automatic memory stack ) in 1972. In this scheme, the key duplicates values into Y under certain conditions (automatic stack lift with temporary stack lift disable), and the top register T ("top") gets duplicated on drops (top copy on pop aka top stack level repetition) in order to ease some calculations and to save keystrokes. HP used reverse Polish notation on every handheld calculator it sold, whether scientific, financial, or programmable, until it introduced the HP-10 adding machine calculator in 1977. By this time, HP was the leading manufacturer of calculators for professionals, including engineers and accountants. Later calculators with LCDs in the early 1980s, such as the HP-10C, HP-11C, HP-15C, HP-16C, and the financial HP-12C calculator also used reverse Polish notation. In 1988, Hewlett-Packard introduced a business calculator, the HP-19B, without reverse Polish notation, but its 1990 successor, the HP-19BII, gave users the option of using algebraic or reverse Polish notation again. In 1986, HP introduced RPL, an object-oriented successor to reverse Polish notation. It deviates from classical reverse Polish notation by using a dynamic stack only limited by the amount of available memory (instead of three or four fixed levels) and which could hold all kinds of data objects (including symbols, strings, lists, matrices, graphics, programs, etc.) instead of just numbers. The system would display an error message when running out of memory instead of just dropping values off the stack on overflow as with fixed-sized stacks. It also changed the behaviour of the stack to no longer duplicate the top register on drops (since in an unlimited stack there is no longer a top register) and the behaviour of the key so that it no longer duplicated values into Y, which had shown to sometimes cause confusion among users not familiar with the specific properties of the automatic memory stack. From 1990 to 2003, HP manufactured the HP-48 series of graphing RPL calculators, followed by the HP-49 series between 1999 and 2008. The last RPL calculator was named HP 50g, introduced in 2006 and discontinued in 2015. However, there are several community efforts like newRPL or DB48X to recreate RPL on modern calculators. As of 2011, Hewlett-Packard was offering the calculator models 12C, 12C Platinum, 17bII+, 20b, 30b, 33s, 35s, 48gII (RPL) and 50g (RPL) which support reverse Polish notation. While calculators emulating classical models continued to support classical reverse Polish notation, new reverse Polish notation models feature a variant of reverse Polish notation, where the key behaves as in RPL. This latter variant is sometimes known as entry RPN. In 2013, the HP Prime introduced a 128-level form of entry RPN called advanced RPN. In contrast to RPL with its dynamic stack, it just drops values off the stack on overflow like other fixed-sized stacks do. However, like RPL, it does not emulate the behaviour of a classical operational RPN stack to duplicate the top register on drops. In late 2017, the list of active models supporting reverse Polish notation included only the 12C, 12C Platinum, 17bii+, 35s, and Prime. By July 2023, only the 12C, 12C Platinum, the HP 15C Collector's Edition, and the Prime remain active models supporting RPN. ==== Commodore ==== In 1974, Commodore produced the Minuteman *6 (MM6) without an key and the Minuteman *6X (MM6X) with an key, both implementing a form of two-level RPN. The SR4921 RPN came with a variant of four-level RPN with stack levels named X, Y, Z, and W (rather than T) and an key (for "entry"). In contrast to Hewlett-Packard's reverse Polish notation implementation, W filled with 0 instead of its contents being duplicated on stack drops. ==== Heathkit ==== The Aircraft Navigation Computer Heathkit OC-1401/OCW-1401 used five-level RPN in 1978. ==== Community-developed hardware-based calculators ==== An eight-level stack was suggested by John A. Ball in 1978. The community-developed calculators WP 34S (2011 ), WP 31S (2014) and WP 34C (2015), which are based on the HP 20b/HP 30b hardware platform, support classical Hewlett-Packard-style reverse Polish notation supporting automatic stack lift behaviour of the key and top register copies on pops, but switchable between a four- and an eight-level operational stack. In addition to the optional support for an eight-level stack, the newer SwissMicros DM42-based WP 43S as well as the WP 43C (2019) / C43 (2022) / C47 (2023) derivatives support data types for stack objects (real numbers, infinite integers, finite integers, complex numbers, strings, matrices, dates and times). The latter three variants can also be switched between classical and entry RPN behaviour of the key, a feature often requested by the community. They also support a rarely seen significant figures mode, which had already been available as a compile-time option for the WP 34S and WP 31S. Since 2021, the HP-42S simulator Free42 version 3 can be enabled to support a dynamic RPN stack only limited by the amount of available memory instead of the classical 4-level stack. This feature was incorporated as a selectable function into the DM42 since firmware DMCP-3.21 / DM42-3.18. (13 of 702 pages) ==External links== [http://rosettacode.org/wiki/Parsing/RPN_calculator_algorithm Rosettacode.org providing many implementations in several programming languages. http://rpn.codeplex.com/ Implementation of RPN with custom functions support and flexible list of operators. https://xrjunque.nom.es/ConvertAlg2RPN_RPL.aspx Free online Algebraic expression to RPN Converter
References
No reference rows published for this article.
Cite this article
MLA
"Reverse Polish notation." encyclopegia.org, 2026, https://encyclopegia.org/wiki/reverse-polish-notation. Accessed 24 November 2026.
Chicago
"Reverse Polish notation." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/reverse-polish-notation.
APA
encyclopegia.org. (2026). Reverse Polish notation. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/reverse-polish-notation
Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON