Renamed the repository as BASIC (Basic Arduino String Input Calculator) cuz that is what its intended for.
Borked the smart implementation based on regex and vector by using buffers of character and double. I also had to implement my own push, pop, length, back, isempty, and empty functions. I had to do that since Arduino doesn't support regex and vectors natively.
Yes I'm aware that there are pre-built regex and vector libraries. But under space constraints, having another library to use the original code doesn't help. That's also why I couldn't use the far more capable tinyexpr.
Will be updating this repo as my code golfing ability improves.
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*21---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
doubledata 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.