A simple calculator that supports BODMAS, nested parentheses, unary operators, variable precision, and more. It uses the Shunting Yard Algorithm to convert an input infix expression to postfix expression before evaluating it.
Enter your mathematical expression : 4*(5-3)^4
Enter precision (number of decimal places): 5
Postfix = 4 5 3 - 4 ^ *
Answer = 64.00000
Download the project using Git (or otherwise) and compile the code in calculator.cpp
.
112+22*(2*(22-53^2*(2))-7/(7/2-1/4)) //-246159.38462
2+-1 // 1
2^0.5 // 1.413
7^7^(2/(4-532)^3) // 7^(7^(2/(4-532)^3)) = 7.0
2(2) // same as 2*2
1---1 //not supported yet
2* //incomplete expression
7 ^ 7 ^ (2/(4-532)^3) //(No spaces between digits/operators are allowed when inputting directly from console)
- Range of numbers is limited by
double
data type. - No support for trigonometric and logarithmic expressions.
- No support for expressions containing irrational numbers (
$\pi$ ,$e$ ,$\ln 3 + 5$ ) - Input is not validated so all invalid inputs will cause program to crash.