Jump to content

# RPN Calculator

## Recommended Posts

Reverse Polish Notation (RPN) is a math notation in which each operator follows its two operands. I own an HP 48G calculator which uses RPN, and when I tried to use the windows calculator I had so much trouble that I wrote my own calculator. Basically, it has a stack of numbers; any time an operator is pressed, that operation is carried out immediately on the two items on the bottom of the stack, or the stack and the input if there is anything in the input. This method reduces the requirements for parenthesis and makes calculating equations/functions relatively easy: instead of

(sqrt(5+8))/(8*9)

you would enter

5 ENTER 8 + SQRT 8 ENTER 9 * /

Practical implications

Suggestions/advice/criticisms are greatly appreciated!

calc2.au3

Edited by darthwhatever

[font=arial, sans-serif]How is education supposed to make me feel smarter? Besides, every time I learn something new, it pushes some old stuff out of my brain. Remember when I took that home winemaking course, and I forgot how to drive?[/font][font=arial, sans-serif]<div>This is how you annoy a web developer.</span>[/font]

##### Share on other sites

Whoops. I was going to add the option for the user to add functions, but decided that was too much of a pain. Attached file is updated.

[font=arial, sans-serif]How is education supposed to make me feel smarter? Besides, every time I learn something new, it pushes some old stuff out of my brain. Remember when I took that home winemaking course, and I forgot how to drive?[/font][font=arial, sans-serif]<div>This is how you annoy a web developer.</span>[/font]

##### Share on other sites

• 1 year later...

if you just type a minus:

---------------------------
AutoIt Error
---------------------------
Line 265  (File "calc2.au3"):

\$aStack[uBound(\$aStack) - 1] -= \$iLast
\$aStack[^ ERROR

Error: Variable subscript badly formatted.
---------------------------
OK
---------------------------

regards,
TheAutomator
Edited by TheAutomator
##### Share on other sites

Thank you for shareing this will help a lot as I am also trying to make a Math Evalulator for a project I am working on.

On Error Resume Pulling Hair Out.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now
• ### Recently Browsing   0 members

• No registered users viewing this page.
• ### Similar Content

• #### simple date calculator

By nacerbaaziz,

• 4 replies
• 1,650 views
• #### PAL timecode calculator UDF

By imitto,

• 1 reply
• 2,148 views
• #### My rpn calculator can't compute negative numbers... 1 2

By TheAutomator,

• 30 replies
• 13,912 views
• #### Shunting-Yard algorithm

By guinness,

• 2 replies
• 7,162 views
• #### Ohm's Law Calculator

By careca,

• 0 comments
• 5,211 views
×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...