Skip to content

JaykeBird/ArithmeticParser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arithmetic-Parser-made-easy

A simple parser/evaluator for math expressions in C#.

The library is built with a .NET Standard 2.0 version, but also versions for .NET Framework 3.5 and 4.5.

How to use

double result = Parser.Evaluate("(3+4)*-2");

If the expression cannot be evaluated (such as Parser.Evaluate("apple");), it will throw a FormatException.

Supported features

  • Addition, subtraction, multiplication, division
  • Exponents (2^3)
  • Decimals (2*(0.3) and 2*(0,3) (depends upon culture, see below))
  • Implied multiplication ((2-3)(4/6) and 3(4+6))
  • Negation (-(4+5))

Note about decimal separators

Some cultures use . for decimal separators (0.5) while others use , (0,5). The decimal separator used depends upon the culture the current thread is running on. If you want it one way or the other, you'll want to change the UI culture.

Learn which cultures use which symbol

License

This code is released under the MIT License.

About

Simple Arithmetic parser made with C#

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%