Giter Club home page Giter Club logo

basic-console-calculator's Introduction

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.

basic-console-calculator's People

Contributors

creme332 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

amooose

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.