View Single Post
Old 06-27-2005, 05:17 PM   #3 (permalink)
Rashakil Fol
Registered User
 
Join Date: Jun 2005
Posts: 3
Rashakil Fol is on a distinguished road
Reverse Polish Notation is a way of writing mathematical notation in which the operators go after the arguments, which does not require parentheses. For example, 3 5 + simplifies to 8, and 4 7 * simplifies to 28. If you write 1 2 3 + +, first the 2 3 + simplifies to 5, then 1 5 + simplifies to 6. The quadratic formula, normally written (-b + sqrt(b*b - 4*a*c)) / (2 * a), would be written as

b b * a c * 4 * - sqrt b - 2 a * /

RPN calculators use a stack to evaluate their expressions, and a basic four-function RPN calculator can be written in one line of Perl. Write one in C++. Search on the Web for more information.

I first read this recommendation in a response to an Ask Slashdot question, by the way :-)
Rashakil Fol is offline   Reply With Quote