Teach Time Encyclopedia - Learn About Our World
Home Page
Teach Time
Featured Topics

United States
by state

CITYology

Academic Disciplines

Historical Timelines

Themed Timelines

Calendars

Reference Tables

Biographies

How-tos



Friday, July 25, 2008

Reverse Polish Notation

Reverse Polish Notation (RPN, or postfix notation) is an arithmetic formula notation, derived from one introduced in 1920 by the Polish mathematician Jan Łukasiewicz. RPN was invented by the Australian philosopher and computer scientist Charles Hamblin in the mid-1950s, to enable zero-address memory stores. It was popularized by the HP-35 calculator in the 1970s. In this notation, the operands precede the operator, thus dispensing with the need for parentheses. For example, the expression 3 * ( 4 + 7) would be written as 3 4 7 + *.

Implementations that use RPN are stack-based; that is, operands are popped from a stack, and calculation results are pushed back onto it. Although this concept may seem obscure at first, RPN has the advantage of being extremely easy for a computer to analyze due to it being a regular grammar. RPN has been used in Hewlett-Packard calculators as well as in some programming languages such as Forth and PostScript. Most Unix systems also come with a calculator program, dc, that uses RPN.

Table of contents
1 Practical implications
2 Example

Practical implications

  • Calculations proceed from left to right
  • There are no brackets or parentheses, as they are unnecessary.
  • Operands precede operator. They are removed as the operation is evaluated.
  • When an operation is made, the result becomes an operand itself (for later operators)

Example

The calculation: ((1 + 2) * 4) + 3 can be written down like this in RPN:
1 2 + 4 * 3 +
The expression is evaluated in the following way (the Stack is displayed after Operation has taken place):
Input Stack Operation
1 1 Push operand
2 1, 2 Push operand
+ 3 Addition
4 3, 4 Push operand
* 12 Multiplication
3 12, 3 Push operand
+ 15 Addition
The final result, 15, lies on the top of the stack in the end of the calculation.

Examples of RPN Use

Compare to Polish notation.

See also Subject Object Verb, Subject Verb Object.



Internet Hotel Solutions

Site Sponsors
AC Units
Baltimore Harbor
Boot Camp Grads
Bra Size
Burkittsville
College Hotels
Digital Harbor
Free Cell Phones
Golden Hare Travel
Golf Vacations
Golf Courses
Gourmet
Hair Styles
Hippodrome
iWoman
Lesson Plans
Maryland Hotels
MD Genealogy
Minor League Stuff
Motel Site
Ocean City
OC Real Estate
Old Agers
Office Supplies
Orlando
Pet Friendly Hotel
Room Prices
Savannah, GA
Ski Vacations
South Baltimore
Student Teaching
Travel Sources
University Hotels
Visit Military Bases
Washington, DC

Brought to you by NoChildLeftBehind.com and the Beaches and Towns Network, LLC.