CalcForge 1.0.0
dotnet add package CalcForge --version 1.0.0
NuGet\Install-Package CalcForge -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CalcForge" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CalcForge" Version="1.0.0" />
<PackageReference Include="CalcForge" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CalcForge --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CalcForge, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CalcForge@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CalcForge&version=1.0.0
#tool nuget:?package=CalcForge&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Evtor — Math Expression Evaluator
Evtor is a lightweight, extensible C# library for parsing and evaluating complex mathematical expressions. It builds an internal token tree (AST-style), supports custom functions via reflection, and offers constant-folding optimizations.
🚀 Features
- Recursive descent parser with full support for nested groups (
(
)
) and multi-parameter functions. - Custom function mapping via
[ValueContainer]
and[FuncMata]
attributes on enums. - Operator precedence:
^
(power),*
//
,+
/-
, bitwise&
,|
, shifts<
>
. - Built-in functions:
Add
,Subtract
,Multiply
,Divide
,Pow
,Abs
,Floor
,Ceiling
,Round
,Max
,Min
,Sqrt
,Log
,Log10
,Exp
,Sin
,Cos
,Tan
,Truncate
,Print
. - Token optimization: constant folding (
0+X
,X*1
,(2+3+4)
) and group simplification. - Tree visualization: pretty-print tokens/groups with
WriteTree
or raw tokens withWriteTokens
.
📦 Installation
Clone or include the
Evtor
source files in your project.Target .NET 8.0 or later.
Add
using
directives:using CalcForge; // Where Evtor classes live
💡 Quick Start
// Simple usage
var evaluator = new Evaluator("Add(2, Multiply(3, (4+5)))");
Console.WriteLine(evaluator.Evaluate()); // 17
// View raw tokens
Evaluator.WriteTokens(evaluator.Tokens);
// View token tree
WriteTree(evaluator.Tokens);
// View optimized token tree
var optimized = evaluator.OptimizeConstants(evaluator.Tokens);
WriteTree(optimized);
🔢 Example with Complex Expression
string Expr = @"((((((2 + 0) + 3) * ((4 * 1) + (0 + 5))) + 2) / (((6 + 6) * 1) * (1 + 0 + 1))) +
((100 / 5) - ((3 + 2) + 0))) +
(((7 * 8) + (9 - 4 + 0)) * (((2 + 3 + 0) * 1) + 2)) -
(((10 + 0 + 5) * 1) * ((6 - 0 - 1))) +
((((50 + 50) / 2) * (((3 + 2) - 0) - (1 + 1)))) + 0 + 0 * 1234 + Add(Pow(20,Sin((20/1*90)+Add(60,70)+90)),20)".Replace("\r\n", "");
Evaluator evaluator = new Evaluator(Expr);
Console.WriteLine(evaluator.Evaluate());
Debugger.WriteTree(evaluator.OptimizedTokens);
Output:
556.6377040595102
└── [Group] ... (token tree output here)
📗 More Examples
// Bitwise and nested logic
Console.WriteLine(new Evaluator("(15 > 1) & 7").Evaluate()); // 7
Console.WriteLine(new Evaluator("(3 < 2) | (1 + 1)").Evaluate()); // 2
// Math with precedence
Console.WriteLine(new Evaluator("(2 + 3) * (4 + 5) ^ 2").Evaluate()); // 2025
// Trigonometry
Console.WriteLine(new Evaluator("Sin(90) + Cos(0)").Evaluate());
// Deep nesting
Console.WriteLine(new Evaluator("Add(1, Add(2, Add(3, Add(4, Add(5, 6)))))").Evaluate());
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.0 | 248 | 5/12/2025 |