JRPN Calculator

Do you ever need to quickly perform long and complicated calculations? Do you loathe managing all those disagreeable parentheses? The little known answer is Reverse Polish Notation (RPN), and JRPN Calculator is a javascript utilization of RPN.

Reverse Polish notation (RPN) is a mathematical notation wherein every operator follows all of its operands, in contrast to Polish notation, which puts the operator in the prefix position. It is also known as Postfix notation and is parenthesis-free as long as operator arities are fixed. The description “Polish” refers to the nationality of logician Jan Lukasiewicz, who invented (prefix) Polish notation in the 1920s.…

In Reverse Polish notation the operators follow their operands; for instance, to add three and four, one would write “3 4 +” rather than “3 + 4”. If there are multiple operations, the operator is given immediately after its second operand; so the expression written “3 – 4 + 5” in conventional infix notation would be written “3 4 – 5 +” in RPN: first subtract 4 from 3, then add 5 to that. An advantage of RPN is that it obviates the need for parentheses that are required by infix. While “3 – 4 * 5” can also be written “3 – (4 * 5)”, that means something quite different from “(3 – 4) * 5”. In postfix, the former would be written “3 4 5 * -“, which unambiguously means “3 (4 5 *) -” which reduces to “3 20 -“.

Interpreters of Reverse Polish notation are often stack-based; that is, operands are pushed onto a stack, and when an operation is performed, its operands are popped from a stack and its result pushed back on. So the value of postfix expression is on the top of the stack. Stacks, and therefore RPN, have the advantage of being easy to implement and very fast.

To install JRPN Calculator download the JRPNCalc .html file.