Reverse Polish Notation

Go down

Reverse Polish Notation

Post by Michael on Thu Oct 30, 2008 4:06 pm

Reverse Polish Notation is a different way of entering equations into a calculator (usually HP, not TI). It allows the user to enter complex equations faster, and also allows the calculator to compute faster using stacks rather than string algorithms.

The numbers are entered backwards: to enter 2+4 on an HP, type 2 ENTER 4 +. Pressing 2 then enter tells the calculator to enter 2 into memory. Then, press 4 and + to add 4 onto the number last stored (at the top of the stack).

Parentheses do not need to be entered. To enter 3*(2+4) type 3 ENTER 2 ENTER 4 + *.


Stacks
Numbers are stored in a stack, with Last In First Out (LIFO). Meaning that the last number entered is the first number removed.

So, taking the equation 3*(2+4), here is the stack as each number is entered in as 3 ENTER 2 ENTER 4 + *.

Starting with an empty stack:
Code:
3 ENTER.
Pushes the 3 into the stack.
Code:
3
2 ENTER.
Pushes the 2 into the stack.
Code:
2
3
4 +.
It removes the 2 at the top and adds 4 to it:
Code:
6
3
*.
As no number is entered, it removes the last 2 numbers in the stacks and multiplies them.
Code:
18
avatar
Michael
Graduated member
Graduated member

Male Number of posts : 151
Age : 27
Registration date : 2008-04-30

View user profile http://elkinschess.forummotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum