Math-Expression-Evaluator 1.4.0

Math Expression Evaluator

NuGet Downloads NuGet Version

Sponsors

Entity Framework Extensions and Dapper Plus are major sponsors and are proud to contribute to the development of Math Expression Evaluator.

Entity Framework Extensions - Sponsor

Dapper Plus - Sponsor

Usage

Math Expression Evaluator is a library for evaluating simple mathematical expressions. It supports simple expressions such as 2.5+5.9, 17.89-2.47+7.16, 5/2/2+1.5*3+4.58, expressions with parentheses (((9-6/2)*2-4)/2-6-1)/(2+24/(2+4)) and expressions with variables:


var a = 6;
var b = 4.32m;
var c = 24.15m;
Assert.That(engine.Evaluate("(((9-a/2)*2-b)/2-a-1)/(2+c/(2+4))", new { a, b, c}), 
            Is.EqualTo((((9 - a / 2) * 2 - b) / 2 - a - 1) / (2 + c / (2 + 4))));

It is also possible to specify variables by using named arguments like this:


dynamic dynamicEngine = new ExpressionEvaluator();

var a = 6;
var b = 4.5m;
var c = 2.6m;
Assert.That(dynamicEngine.Evaluate("(c+b)*a", a: 6, b: 4.5, c: 2.6),
            Is.EqualTo((c + b) * a));

Installation

dotnet add package Math-Expression-Evaluator

User Feedback

From https://stackoverflow.com/questions/50722680/methods-for-dynamically-creating-an-array-in-c-sharp

DavidG

Can't decide if this library is evil, genius or evil genius...

xanatos

That library is using high level magic... Very high level :-)

The class is dynamic and is handling in a dynamic way the use of the method... fascinating

Showing the top 20 packages that depend on Math-Expression-Evaluator.

Packages Downloads
com.abbeoo.sw.core.net.http.expression
Jasmin Application Logic based on build 6a24578e9924128f957b6a49ac9d578ec51939c8 based on build 7cc4e39d2397a97c37ef68f0ee89776c03491ad4
12
com.abbeoo.sw.jasmin.core.net.expressions
Jasmin Application Logic based on build 0096658f1c520617de1d56242fe95df353b17638
8
com.abbeoo.sw.jasmin.core.net.expressions
Jasmin Application Logic based on build 6a24578e9924128f957b6a49ac9d578ec51939c8
8
com.abbeoo.sw.core.net.http.expression
Jasmin Application Logic based on build 6a24578e9924128f957b6a49ac9d578ec51939c8 based on build b612276911d493329192b1df34a23f3f0f8b2400
7
com.abbeoo.sw.core.net.http.expression
Jasmin Application Logic based on build 6a24578e9924128f957b6a49ac9d578ec51939c8 based on build 34c8685cb95d7d23c21407ab995cfabce130a766
6
com.abbeoo.sw.core.net.http.StringToExpression
Description
6
com.abbeoo.sw.core.net.http.StringToExpression
Description
4

The library now targets .NET Standard 2.0

.NET Standard 2.0

  • No dependencies.

Version Downloads Last updated
1.4.0 6 06/26/2025
1.3.2 7 01/30/2025
1.3.0 6 02/20/2025
1.2.0 5 11/18/2024
1.1.0 5 07/07/2025
1.0.0 7 03/19/2025