Mathematical Precedence in calculations performed at run time.
Hi,
I am working on a sub component of my application that is forming the basis for my PhD.
What I am trying to is evaluate simple mathematical expressions such as: 1 + 2 * 3 - 1 * 2 / 3.
The expressions are entered by the user at run time. Program variables have been substituted for their actual values to build the mathematical string.
The argument is broken down into tokens stored in a Vector
i.e.: [1] [+] [2] [*] [3] -[1] [*][2] [/] [3]
What I need now is a good algorithm to be able to calculate the result given the mathematical order of precedence {Division, Multiplication}{Subtraction, Addition}.
I would also like to be able to do error checking within this, so that the algorithm can be used for evaluation as well as calculation.
Any ideas?
Thanks

