Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

Latest commit

 

History

History
42 lines (29 loc) · 1.25 KB

README.md

File metadata and controls

42 lines (29 loc) · 1.25 KB

Calculator 🔰

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

🚀 Usage

Download the project using Git (or otherwise) and compile the code in calculator.cpp.

👍 Examples of valid expressions

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

👎 Examples of invalid expressions

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)

🛑 Current limitations

  • 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.