0
\$\begingroup\$

Possible Duplicate:
Advanced Calculator

The goal of this is to take a mathematical expression, evaluate it, and return the value. The value of the input string will never be more than 2^31-1, less than -2^31, and it will never be a decimal. There will also be no "compressed multiplation", e.x. 2(3-2).

You cannot use eval(), exec(), or any other command that evaluates a string.

The input of this will only have parentheses, exponents, multiplication, division, subtraction, and addition. The Order of Operations will be used.

Here are some test strings you can put in:

2^(9/3)+4*(3-2)=12
5-6*(4/2)=-7
(2+3-5*54/3^2)^4=1500625
\$\endgroup\$

marked as duplicate by dmckee Apr 1 '12 at 15:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Browse other questions tagged or ask your own question.