StringMath 2.0.0
See the version list below for details.
dotnet add package StringMath --version 2.0.0
NuGet\Install-Package StringMath -Version 2.0.0
<PackageReference Include="StringMath" Version="2.0.0" />
paket add StringMath --version 2.0.0
#r "nuget: StringMath, 2.0.0"
// Install StringMath as a Cake Addin #addin nuget:?package=StringMath&version=2.0.0 // Install StringMath as a Cake Tool #tool nuget:?package=StringMath&version=2.0.0
Creating and using a calculator
Calculator myCalculator = new Calculator();
decimal result = myCalculator.Evaluate("1 * (2 - 3) ^ 2"); // 1
// Using custom operators
myCalculator.AddOperator("abs", a => a > 0 ? a : -a);
decimal result = myCalculator.Evaluate("abs -5"); // 5
// Using custom operator precedence (you can specify an int for precedence)
myCalculator.AddOperator("max", (a, b) => a > b ? a : b, Precedence.Power);
decimal result = myCalculator.Evaluate("2 * 3 max 4"); // 8
Creating and using variables
Replacements variables = new Replacements
{
["a"] = 5,
["PI"] = 3.1415926535897931
};
Calculator myCalculator = new Calculator(variables);
// Replacing existing variables
myCalculator.Replace("a", 2);
myCalculator.Replace("b", 1);
decimal result = calculator.Evaluate("{a} + 2 * {b} + {PI}"); // 7.1415926535897931
Using the static api: SMath
// Same API as a calculator instance except the Evaluate method
decimal result = SMath.Evaluate("1 + 1"); // 2
decimal result = SMath.Evaluate("1 + {myVar}", new Replacements { ["myVar"] = 1 }); // 2
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on StringMath:
Package | Downloads |
---|---|
KS.CoreCLR
Simulates our future-planned kernel |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on StringMath:
Repository | Stars |
---|---|
miroiu/nodify
Highly performant and modular controls for node-based editors designed for data-binding and MVVM.
|
Create an instance of a Calculator with custom operators and variables or use the static class SMath.
Specify the operator's precedence when creating a new one or overwriting an existing one.
Create custom operators using both letters and different characters than letters.
Added more default operators.
Added default replacements for Calculator instances (PI, E).
The Replacement's api was changed to use a Replacements collection instead of an array of Replacement objects.