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

Simple calculator that supports BODMAS, nested parentheses, unary operators, and more. Precision of output can be varied.

License

Notifications You must be signed in to change notification settings

creme332/basic-console-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Releases

No releases published

Packages

No packages published

Languages