Skip to content

This is a basic math interpreter written in C#. It can be used to perform basic calculations.

License

Notifications You must be signed in to change notification settings

CoolDeveloper101/simple-math-interpreter

Repository files navigation

Simple Math Interpreter

build

This is the new version of the math interpreter since it got extremely hard to update and add new tests to it. So this is the same interpreter with a better structure so it is easier to maintain. You can find the original project here.

Credits

Thanks to CodePulse for the original project. He created the original interpreter in python and I basically converted to a C# project. You can find the original source code here. Thanks to CodePulse for the project.

Usage

The interpreter supports the following oprators in the given precedence-
Brackets : ( )
Exponent : **
Exponent : !
Division : /
Multiplication : *
Addition : +
Subtraction : -

It supports positive as well as negative numbers and also supports decimal numbers.

Note: Some of you might be wondering why there is not underroot operator. After much consideration, I decided that it was really unnecessary. Well you can just use this property - number1/x is equal to xth root of the number.

For example:

41/2 is equal to square root of 4 which is 2
271/3 is equal to cube root of 27 which is 3
and so on...

So, to perform the under root operation in the calualator for any number, lets say 144- >>> 144 ** (1/2) The parentheses are important as the power operator is upper in the operator hierarchy. If the don't include them the result would become- >>> (144 ** 1) / 2

Use the console.

To use the math interpreter console, follow the given steps -

  1. Install the dotnet core sdk
  2. Clone the repository
  3. Navigate to <repo_location>/Mathinterpreter.console/ directory in the terminal. (Where <repo_location> is the directory where you cloned the repo.)
  4. Run the command dotnet run in the terminal.
  5. It prompts you for input. Enter any valid mathematical expression as stated above.

Integrating with other applications.

Since the core application is a dotnet standard class library, it is easily portable. Just add a refernce to the MathInterpreter.MathInterpreter.csproj file in your project.

Contributions

Conbtributing

About

This is a basic math interpreter written in C#. It can be used to perform basic calculations.

Topics

Resources

License

Stars

Watchers

Forks

Languages