uCalc Fast Math Parser is Easy Fast Flexible Powerful Modern Cross-platform Extensible Reliable a Time-saver Dependable Cost-effective Customizable Intuitive Feature-rich Longstanding (since the 90s) Still Evolving a Powerhouse Useful Not just for math Just what you're looking for!

The classic expression evaluator. Now supercharged by the token-aware Transformer engine.

The Next Generation of Math Parsing

For decades, uCalc Fast Math Parser has been a trusted high-performance expression evaluator that allows programs to evaluate mathematical expressions defined by users at runtime. Today, that same fast math engine serves as a foundational core of the new uCalc SDK. You still get the fast evaluator and custom function definitions you love, now with the added power of seamless token-aware string pattern searches and transformations.

High Performance

Optimized for evaluating math expressions millions of times per second in a tight loop.

Customizable

Easily define custom algebraic functions and variables at runtime.

Cross-platform

Fully compatible with both modern .NET Core and legacy .NET Framework, C#, C++, and VB.NET across various platforms.

uCalc Fast Math Parser is Easy

As easy as it gets

uCalc abstracts away the underlying complexity of parsing.  Define your variables and custom functions easily, then evaluate your math expression with a simple call to Eval (or EvalStr). Try it out for yourself right here on this page to see just how easy it is. Then download a copy for yourself.

A minimal example defining a function inline to calculate the area of a rectangle.

ID: 296

				
					using uCalcSoftware;

var uc = new uCalc();
uc.DefineVariable("x = 5");
uc.DefineFunction("Area(length, width) = length * width");
Console.WriteLine(uc.Eval("Area(4, x) + 7"));
				
			
27
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uc.DefineVariable("x = 5");
   uc.DefineFunction("Area(length, width) = length * width");
   cout << uc.Eval("Area(4, x) + 7") << endl;
}
				
			
27
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      uc.DefineVariable("x = 5")
      uc.DefineFunction("Area(length, width) = length * width")
      Console.WriteLine(uc.Eval("Area(4, x) + 7"))
   End Sub
End Module
				
			
27

uCalc Fast Math Parser is Fast

uCalc

Don't blink or you'll miss it

Achieve rapid execution speeds. uCalc separates the heavy lifting of parsing from the execution with its "Parse-Once, Evaluate-Many" architecture, making it blazing fast inside tight loops.

Benchmarking Tip: Clicking "Run" in this online example includes the overhead of network routing and remote compilation. To see the actual evaluation speed (which is near-instantaneous regardless of loop size), uncomment the StopWatch line to print the exact execution time of the loop itself, excluding online overhead.

Note: If you think the preview version is fast, wait until the optimized production release comes out.

Using the parse-evaluate pattern for high-performance calculations in a loop with a changing variable w/ stopwatch.

ID: 1460

				
					using uCalcSoftware;

var uc = new uCalc();
var variableX = uc.DefineVariable("x");
var userExpression = "x * 2 + 5";
var Total = 0.0;
var UpperBound = 1000000; // One million

// Parse the expression just once before the loop begins.
var parsedExpr = uc.Parse(userExpression);

var stopwatch = System.Diagnostics.Stopwatch.StartNew();
for (double x = 1; x <= UpperBound; x++) {
   variableX.Value(x);
   Total = Total + parsedExpr.Evaluate();
}
stopwatch.Stop();
//Uncomment the following line to reveal the actual speed:
//Console.WriteLine($"Elapsed Milliseconds: {stopwatch.ElapsedMilliseconds} ms");

Console.Write("Sum(1, "); Console.Write(UpperBound); Console.Write(", "); Console.Write(userExpression); Console.Write(") = "); Console.Write(Total);
				
			
Sum(1, 1000000, x * 2 + 5) = 1000006000000
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto variableX = uc.DefineVariable("x");
   auto userExpression = "x * 2 + 5";
   auto Total = 0.0;
   auto UpperBound = 1000000; // One million

   // Parse the expression just once before the loop begins.
   auto parsedExpr = uc.Parse(userExpression);


   for (double x = 1; x <= UpperBound; x++) {
      variableX.Value(x);
      Total = Total + parsedExpr.Evaluate();
   }

   cout << "Sum(1, " << UpperBound << ", " << userExpression << ") = " << (long long)Total;
}
				
			
Sum(1, 1000000, x * 2 + 5) = 1000006000000
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim variableX = uc.DefineVariable("x")
      Dim userExpression = "x * 2 + 5"
      Dim Total = 0.0
      Dim UpperBound = 1000000 '// One million
      
      '// Parse the expression just once before the loop begins.
      Dim parsedExpr = uc.Parse(userExpression)
      
      Dim stopwatch = System.Diagnostics.Stopwatch.StartNew()
      For x  As Double = 1 To UpperBound
         variableX.Value(x)
         Total = Total + parsedExpr.Evaluate()
      Next
      stopwatch.Stop()
      '//Uncomment the following line to reveal the actual speed:
      '//Console.WriteLine($"Elapsed Milliseconds: {stopwatch.ElapsedMilliseconds} ms");
      
      Console.Write("Sum(1, ")
      Console.Write(UpperBound)
      Console.Write(", ")
      Console.Write(userExpression)
      Console.Write(") = ")
      Console.Write(Total)
   End Sub
End Module
				
			
Sum(1, 1000000, x * 2 + 5) = 1000006000000

Ready to improve your productivity with uCalc Fast Math Parser?

uCalc Fast Math Parser is Flexible

Beyond user functions

Adapt the engine to your exact needs. uCalc's grammar is fully dynamic, letting you invent new operators, custom functions, and even define your own Domain-Specific Languages (DSLs) on the fly.

Defines a custom `sum_to` operator to calculate the sum of a numeric range, demonstrating a single-word operator.

ID: 1224

				
					using uCalcSoftware;

var uc = new uCalc();
// Define the variables that the operator's expression will use.
uc.DefineVariable("i");
uc.DefineVariable("total");

// Define a new 'sum_to' operator at runtime, with precedence level of 50.
// It uses the built-in ForLoop function to sum numbers into the 'total' variable.
uc.DefineOperator("{start} sum_to {end} = total = 0; ForLoop(i, start, end, 1, total = total + i)", 50);

// Use the new operator. The result is stored in the 'total' variable.
uc.Eval("1 sum_to 5");

Console.WriteLine($"The sum from 1 to 5 is: {uc.Eval("total")}");
				
			
The sum from 1 to 5 is: 15
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   // Define the variables that the operator's expression will use.
   uc.DefineVariable("i");
   uc.DefineVariable("total");

   // Define a new 'sum_to' operator at runtime, with precedence level of 50.
   // It uses the built-in ForLoop function to sum numbers into the 'total' variable.
   uc.DefineOperator("{start} sum_to {end} = total = 0; ForLoop(i, start, end, 1, total = total + i)", 50);

   // Use the new operator. The result is stored in the 'total' variable.
   uc.Eval("1 sum_to 5");

   cout << "The sum from 1 to 5 is: " << uc.Eval("total") << endl;
}
				
			
The sum from 1 to 5 is: 15
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      '// Define the variables that the operator's expression will use.
      uc.DefineVariable("i")
      uc.DefineVariable("total")
      
      '// Define a new 'sum_to' operator at runtime, with precedence level of 50.
      '// It uses the built-in ForLoop function to sum numbers into the 'total' variable.
      uc.DefineOperator("{start} sum_to {end} = total = 0; ForLoop(i, start, end, 1, total = total + i)", 50)
      
      '// Use the new operator. The result is stored in the 'total' variable.
      uc.Eval("1 sum_to 5")
      
      Console.WriteLine($"The sum from 1 to 5 is: {uc.Eval("total")}")
   End Sub
End Module
				
			
The sum from 1 to 5 is: 15

uCalc Fast Math Parser is Powerful

Check this out

Go way beyond basic math. From handling complex boolean logic to executing multi-pass text transformations, uCalc brings a token-aware engine that easily outsmarts standard regular expressions.

Applies `RewindOnChange` to a default rule set to enable complex, multi-rule transformations for a custom `Average` function.

ID: 981

				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.ExpressionTransformer;

// Enable rewind for all subsequent rules in this transformer.
t.DefaultRuleSet.SetRewindOnChange(true);

// Define the recursive rules.
t.FromTo("AddUp({x})", "{x}");
t.FromTo("AddUp({x}, {y})", "({x} + AddUp({y}))");

t.FromTo("ArgCount({x})", "1");
t.FromTo("ArgCount({x}, {y})", "(1 + ArgCount({y}))");

// The main rule that combines the others.
t.FromTo("Average({x}, {y})", "AddUp({x}, {y}) / ArgCount({x}, {y})");

var expression = "Average(1, 2, 3, 4)";
Console.WriteLine($"Input: {expression}");
Console.WriteLine($"Transform: {t.Transform(expression)}");
Console.WriteLine($"Eval: {uc.Eval(expression)}");
				
			
Input: Average(1, 2, 3, 4)
Transform: (1 + (2 + (3 + 4))) / (1 + (1 + (1 + 1)))
Eval: 2.5
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.ExpressionTransformer();

   // Enable rewind for all subsequent rules in this transformer.
   t.DefaultRuleSet().SetRewindOnChange(true);

   // Define the recursive rules.
   t.FromTo("AddUp({x})", "{x}");
   t.FromTo("AddUp({x}, {y})", "({x} + AddUp({y}))");

   t.FromTo("ArgCount({x})", "1");
   t.FromTo("ArgCount({x}, {y})", "(1 + ArgCount({y}))");

   // The main rule that combines the others.
   t.FromTo("Average({x}, {y})", "AddUp({x}, {y}) / ArgCount({x}, {y})");

   auto expression = "Average(1, 2, 3, 4)";
   cout << "Input: " << expression << endl;
   cout << "Transform: " << t.Transform(expression) << endl;
   cout << "Eval: " << uc.Eval(expression) << endl;
}
				
			
Input: Average(1, 2, 3, 4)
Transform: (1 + (2 + (3 + 4))) / (1 + (1 + (1 + 1)))
Eval: 2.5
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.ExpressionTransformer
      
      '// Enable rewind for all subsequent rules in this transformer.
      t.DefaultRuleSet.SetRewindOnChange(true)
      
      '// Define the recursive rules.
      t.FromTo("AddUp({x})", "{x}")
      t.FromTo("AddUp({x}, {y})", "({x} + AddUp({y}))")
      
      t.FromTo("ArgCount({x})", "1")
      t.FromTo("ArgCount({x}, {y})", "(1 + ArgCount({y}))")
      
      '// The main rule that combines the others.
      t.FromTo("Average({x}, {y})", "AddUp({x}, {y}) / ArgCount({x}, {y})")
      
      Dim expression = "Average(1, 2, 3, 4)"
      Console.WriteLine($"Input: {expression}")
      Console.WriteLine($"Transform: {t.Transform(expression)}")
      Console.WriteLine($"Eval: {uc.Eval(expression)}")
   End Sub
End Module
				
			
Input: Average(1, 2, 3, 4)
Transform: (1 + (2 + (3 + 4))) / (1 + (1 + (1 + 1)))
Eval: 2.5

uCalc Fast Math Parser is Useful

Making a spreadsheet?

Solve real-world problems out of the box. Whether you're building a spreadsheet evaluator, a unit converter, or a robust command-line REPL, uCalc provides the practical tools you need to get the job done.

Here, we use Overwrite to handle formula dependency.

A practical example simulating a small spreadsheet with interdependent cells.

ID: 1380

				
					using uCalcSoftware;

var uc = new uCalc();
// Define interdependent 'cells' using the Overwrite command.
uc.Define("Overwrite ~~ Function: A1() = 10");
uc.Define("Overwrite ~~ Function: B1() = A1() * 2");
uc.Define("Overwrite ~~ Function: C1() = A1() + B1()");

Console.WriteLine($"Initial C1: {uc.Eval("C1()")}"); // Should be 10 + (10 * 2) = 30

// Now, overwrite the source cell A1. All dependent cells should automatically update.
uc.Define("Overwrite ~~ Function: A1() = 50");

Console.WriteLine($"Updated B1: {uc.Eval("B1()")}"); // Should now be 50 * 2 = 100
Console.WriteLine($"Updated C1: {uc.Eval("C1()")}"); // Should now be 50 + 100 = 150
				
			
Initial C1: 30
Updated B1: 100
Updated C1: 150
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   // Define interdependent 'cells' using the Overwrite command.
   uc.Define("Overwrite ~~ Function: A1() = 10");
   uc.Define("Overwrite ~~ Function: B1() = A1() * 2");
   uc.Define("Overwrite ~~ Function: C1() = A1() + B1()");

   cout << "Initial C1: " << uc.Eval("C1()") << endl; // Should be 10 + (10 * 2) = 30

   // Now, overwrite the source cell A1. All dependent cells should automatically update.
   uc.Define("Overwrite ~~ Function: A1() = 50");

   cout << "Updated B1: " << uc.Eval("B1()") << endl; // Should now be 50 * 2 = 100
   cout << "Updated C1: " << uc.Eval("C1()") << endl; // Should now be 50 + 100 = 150
}
				
			
Initial C1: 30
Updated B1: 100
Updated C1: 150
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      '// Define interdependent 'cells' using the Overwrite command.
      uc.Define("Overwrite ~~ Function: A1() = 10")
      uc.Define("Overwrite ~~ Function: B1() = A1() * 2")
      uc.Define("Overwrite ~~ Function: C1() = A1() + B1()")
      
      Console.WriteLine($"Initial C1: {uc.Eval("C1()")}") '// Should be 10 + (10 * 2) = 30
      
      '// Now, overwrite the source cell A1. All dependent cells should automatically update.
      uc.Define("Overwrite ~~ Function: A1() = 50")
      
      Console.WriteLine($"Updated B1: {uc.Eval("B1()")}") '// Should now be 50 * 2 = 100
      Console.WriteLine($"Updated C1: {uc.Eval("C1()")}") '// Should now be 50 + 100 = 150
   End Sub
End Module
				
			
Initial C1: 30
Updated B1: 100
Updated C1: 150

uCalc Fast Math Parser is Expandable

Extend uCalc using callbacks

Extend uCalc beyond built-in functionality using callbacks to your own algorithms.  Integrate seamlessly with your existing codebase. You can easily bind uCalc to your high-performance native host functions using direct callbacks, passing arguments by reference, by handle, or unevaluated expressions (ByExpr).

Passing arg ByExpr (delayed lazy eval) and ByHandle

ID: 14

				
					using uCalcSoftware;

var uc = new uCalc();

static void MySum(uCalc.Callback cb) {
   var Total = 0.0;
   var Expr = cb.ArgExpr(1);
   var Start = cb.Arg(2);
   var Finish = cb.Arg(3);
   var Variable = cb.ArgItem(4);

   for (double x = Start; x <= Finish; x++) {
      Variable.Value(x);
      Total += Expr.Evaluate();
   }
   cb.Return(Total);
}

uc.DefineVariable("x");
uc.DefineFunction("Sum(ByExpr Expr, Start, Finish, ByHandle Var)", MySum);
Console.WriteLine(uc.Eval("Sum(x ^ 2, 1, 10, x)"));

				
			
385
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

void ucalc_call MySum(uCalcBase::Callback cb) {
   auto Total = 0.0;
   auto Expr = cb.ArgExpr(1);
   auto Start = cb.Arg(2);
   auto Finish = cb.Arg(3);
   auto Variable = cb.ArgItem(4);

   for (double x = Start; x <= Finish; x++) {
      Variable.Value(x);
      Total += Expr.Evaluate();
   }
   cb.Return(Total);
}
int main() {
   uCalc uc;
   uc.DefineVariable("x");
   uc.DefineFunction("Sum(ByExpr Expr, Start, Finish, ByHandle Var)", MySum);
   cout << uc.Eval("Sum(x ^ 2, 1, 10, x)") << endl;

}
				
			
385
				
					Imports System
Imports uCalcSoftware
Public Module Program
   
   Public Sub MySum(ByVal cb As uCalc.Callback)
      Dim Total = 0.0
      Dim Expr = cb.ArgExpr(1)
      Dim Start = cb.Arg(2)
      Dim Finish = cb.Arg(3)
      Dim Variable = cb.ArgItem(4)
      
      For x  As Double = Start To Finish
         Variable.Value(x)
         Total += Expr.Evaluate()
      Next
      cb.Return(Total)
   End Sub
   Public Sub Main()
      Dim uc As New uCalc()
      uc.DefineVariable("x")
      uc.DefineFunction("Sum(ByExpr Expr, Start, Finish, ByHandle Var)", AddressOf MySum)
      Console.WriteLine(uc.Eval("Sum(x ^ 2, 1, 10, x)"))
      
   End Sub
End Module
				
			
385

uCalc Fast Math Parser is Reliable

Error handling with uCalc

Don't just crash or give unreliable output on bad input. uCalc offers a secure sandboxed environment and a proactive state-based error-handling system, empowering you to intercept, inspect, and recover from user errors gracefully.

A practical example of a proactive error handler that automatically defines undeclared variables on the fly, allowing the expression to successfully resume execution.

ID: 1190

				
					using uCalcSoftware;

var uc = new uCalc();

// This handler automatically defines variables when they are first used.
static void AutoDefineHandler(Handle_uCalc h) {
   var uc = new uCalc(h);
   // Check if the error is specifically an undefined identifier
   if (uc.Error.Code == ErrorCode.Undefined_Identifier) {
      Console.WriteLine($"Handler: '{uc.Error.Symbol}' is undefined. Defining it now.");
      uc.DefineVariable(uc.Error.Symbol);

      // Tell the engine to resume the operation
      uc.Error.Response = ErrorHandlerResponse.Resume;
   }
}


uc.Error.AddHandler(AutoDefineHandler);

// 'my_var' doesn't exist yet, but the handler will create it.
var result = uc.EvalStr("my_var = 100; my_var = my_var * 2");

Console.WriteLine($"Final result: {result}");
				
			
Handler: 'my_var' is undefined. Defining it now.
Final result: 200
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

// This handler automatically defines variables when they are first used.
void ucalc_call AutoDefineHandler(Handle_uCalc h) {
   auto uc = uCalc(h);
   // Check if the error is specifically an undefined identifier
   if (uc.Error().Code() == ErrorCode::Undefined_Identifier) {
      cout << "Handler: '" << uc.Error().Symbol() << "' is undefined. Defining it now." << endl;
      uc.DefineVariable(uc.Error().Symbol());

      // Tell the engine to resume the operation
      uc.Error().Response(ErrorHandlerResponse::Resume);
   }
}

int main() {
   uCalc uc;
   uc.Error().AddHandler(AutoDefineHandler);

   // 'my_var' doesn't exist yet, but the handler will create it.
   auto result = uc.EvalStr("my_var = 100; my_var = my_var * 2");

   cout << "Final result: " << result << endl;
}
				
			
Handler: 'my_var' is undefined. Defining it now.
Final result: 200
				
					Imports System
Imports uCalcSoftware
Public Module Program
   
   '// This handler automatically defines variables when they are first used.
   Public Sub AutoDefineHandler(ByVal h As Handle_uCalc)
      Dim uc As New uCalc(h)
      '// Check if the error is specifically an undefined identifier
      If uc.Error.Code = ErrorCode.Undefined_Identifier Then
         Console.WriteLine($"Handler: '{uc.Error.Symbol}' is undefined. Defining it now.")
         uc.DefineVariable(uc.Error.Symbol)
         
         '// Tell the engine to resume the operation
         uc.Error.Response = ErrorHandlerResponse.Resume
      End If
   End Sub
   
   Public Sub Main()
      Dim uc As New uCalc()
      uc.Error.AddHandler(AddressOf AutoDefineHandler)
      
      '// 'my_var' doesn't exist yet, but the handler will create it.
      Dim result = uc.EvalStr("my_var = 100; my_var = my_var * 2")
      
      Console.WriteLine($"Final result: {result}")
   End Sub
End Module
				
			
Handler: 'my_var' is undefined. Defining it now.
Final result: 200

uCalc Fast Math Parser is Dependable

Easy memory management

Built for robust enterprise use. With proper memory management and thread isolation patterns, you can safely deploy uCalc across multi-threaded applications without risking state corruption or memory leaks.

"using" (C#) and Owned (C++) for auto-releasing uCalc object

ID: 161

				
					using uCalcSoftware;

var uc = new uCalc();

// In C# and VB you should use "using".
// In C++ you can flag a uCalc object for
// auto-release with Owned(), or by setting
// the last parameter of the constructor to true.

uc.IsDefault = true; // Set uc as the default uCalc object
uCalc.DefaultInstance.DefineVariable("Value = 'Original uc object'");
Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")); // Outputs: Original uc object

// Use "using" so that the object is auto-released when it it goes out of scope
using (var uCalcTemp = new uCalc()) {
   uCalcTemp.IsDefault = true; // Set uCalcTemp as the default uCalc object
   uCalc.DefaultInstance.DefineVariable("Value = 'uCalcTemp object'");
   Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")); // uCalcTemp object
}
// uCalcTemp goes out of scope here, and the default uCalc object reverts back to uc

Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")); // Original uc object

{
   /*using*/ var uCalcSticky = new uCalc(); // remains the default even after going out of scope
   uCalcSticky.IsDefault = true; // Set uCalcSticky as the default uCalc object
   uCalc.DefaultInstance.DefineVariable("Value = 'uCalcSticky object'");
   Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")); // Outputs: uCalcSticky object
}    // The uCalcSticky object itself goes out of scope here, but internally it remains the default uCalc object

Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value"));
				
			
Original uc object
uCalcTemp object
Original uc object
uCalcSticky object
uCalcSticky object
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;

   // In C# and VB you should use "using".
   // In C++ you can flag a uCalc object for
   // auto-release with Owned(), or by setting
   // the last parameter of the constructor to true.

   uc.IsDefault(true); // Set uc as the default uCalc object
   uCalc::DefaultInstance().DefineVariable("Value = 'Original uc object'");
   cout << uCalc::DefaultInstance().EvalStr("Value") << endl; // Outputs: Original uc object


   {
      uCalc uCalcTemp;
      uCalcTemp.Owned(); // Causes uCalcTemp to be released when it goes out of scope // Make uCalcTemp owned so it reverts back to uc when uCalcTemp goes out of scope
      uCalcTemp.IsDefault(true); // Set uCalcTemp as the default uCalc object
      uCalc::DefaultInstance().DefineVariable("Value = 'uCalcTemp object'");
      cout << uCalc::DefaultInstance().EvalStr("Value") << endl; // uCalcTemp object
   }
   // uCalcTemp goes out of scope here, and the default uCalc object reverts back to uc

   cout << uCalc::DefaultInstance().EvalStr("Value") << endl; // Original uc object

   {
      uCalc uCalcSticky; // remains the default even after going out of scope
      uCalcSticky.IsDefault(true); // Set uCalcSticky as the default uCalc object
      uCalc::DefaultInstance().DefineVariable("Value = 'uCalcSticky object'");
      cout << uCalc::DefaultInstance().EvalStr("Value") << endl; // Outputs: uCalcSticky object
   }    // The uCalcSticky object itself goes out of scope here, but internally it remains the default uCalc object

   cout << uCalc::DefaultInstance().EvalStr("Value") << endl;
}
				
			
Original uc object
uCalcTemp object
Original uc object
uCalcSticky object
uCalcSticky object
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      
      '// In C# and VB you should use "using".
      '// In C++ you can flag a uCalc object for
      '// auto-release with Owned(), or by setting
      '// the last parameter of the constructor to true.
      
      uc.IsDefault = true '// Set uc as the default uCalc object
      uCalc.DefaultInstance.DefineVariable("Value = 'Original uc object'")
      Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")) '// Outputs: Original uc object
      
      '// Use "using" so that the object is auto-released when it it goes out of scope
      Using uCalcTemp As New uCalc()
         uCalcTemp.IsDefault = true '// Set uCalcTemp as the default uCalc object
         uCalc.DefaultInstance.DefineVariable("Value = 'uCalcTemp object'")
         Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")) '// uCalcTemp object
      End Using
      '// uCalcTemp goes out of scope here, and the default uCalc object reverts back to uc
      
      Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")) '// Original uc object
      
      If True Then
         Dim uCalcSticky As New uCalc() '// remains the default even after going out of scope
         uCalcSticky.IsDefault = true '// Set uCalcSticky as the default uCalc object
         uCalc.DefaultInstance.DefineVariable("Value = 'uCalcSticky object'")
         Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")) '// Outputs: uCalcSticky object
      End If    '// The uCalcSticky object itself goes out of scope here, but internally it remains the default uCalc object
      
      Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value"))
   End Sub
End Module
				
			
Original uc object
uCalcTemp object
Original uc object
uCalcSticky object
uCalcSticky object

uCalc Fast Math Parser is Cross-platform

uCalc on Mac, Linux, Windows

Write once, integrate anywhere. uCalc provides a consistent API across languages such as C++, C#, and VB.NET, on platforms including Windows (x86, x64, and ARM64), Linux (x64 and ARM64), and Mac (x64 and ARM64). This allows you to bring its dynamic parsing capabilities to any modern development environment seamlessly.

uCalc’s Linux binaries are intentionally compiled against GLIBC 2.31 on Ubuntu 20.04 to guarantee execution across nearly any modern or legacy Linux distribution.

uCalc feels at home in the cloud.  Interactive online examples for uCalc on this site run on a Debian Linux AWS server via Docker.

Creating isolated evaluation contexts.

ID: 256

				
					using uCalcSoftware;

var uc = new uCalc();
var main = new uCalc();
main.DefineVariable("rate = 0.05");

var scenarioA = main.Clone();
var scenarioB = main.Clone();

scenarioA.DefineVariable("rate = 0.10");
scenarioB.DefineVariable("rate = 0.20");

Console.WriteLine($"A: {scenarioA.Eval("1000 * rate")}");
Console.WriteLine($"B: {scenarioB.Eval("1000 * rate")}");
Console.WriteLine($"Main: {main.Eval("1000 * rate")}");
main.Release();
scenarioA.Release();
scenarioB.Release();

				
			
A: 100
B: 200
Main: 50
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc main;
   main.DefineVariable("rate = 0.05");

   auto scenarioA = main.Clone();
   auto scenarioB = main.Clone();

   scenarioA.DefineVariable("rate = 0.10");
   scenarioB.DefineVariable("rate = 0.20");

   cout << "A: " << scenarioA.Eval("1000 * rate") << endl;
   cout << "B: " << scenarioB.Eval("1000 * rate") << endl;
   cout << "Main: " << main.Eval("1000 * rate") << endl;
   main.Release();
   scenarioA.Release();
   scenarioB.Release();

}
				
			
A: 100
B: 200
Main: 50
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim main As New uCalc()
      main.DefineVariable("rate = 0.05")
      
      Dim scenarioA = main.Clone()
      Dim scenarioB = main.Clone()
      
      scenarioA.DefineVariable("rate = 0.10")
      scenarioB.DefineVariable("rate = 0.20")
      
      Console.WriteLine($"A: {scenarioA.Eval("1000 * rate")}")
      Console.WriteLine($"B: {scenarioB.Eval("1000 * rate")}")
      Console.WriteLine($"Main: {main.Eval("1000 * rate")}")
      main.Release()
      scenarioA.Release()
      scenarioB.Release()
      
   End Sub
End Module
				
			
A: 100
B: 200
Main: 50

uCalc Fast Math Parser is Cost-effective

uCalc is Free for many users

Many users are eligible to use uCalc for free for non-commercial or commercial purposes alike, with no time limits or restricted functionality.  Check the license to see if you or your organization qualify for a free license.

If payment is required for your business to use uCalc commercially, you will find uCalc Fast Math Parser cost-effective for your enterprise in several ways.  Because uCalc is feature-rich and very extensible, you may not need to purchase additional software tools to meet your needs.  Because uCalc is designed to be robust, you can spend more time working on your products instead of tracking down issues with the parser.  uCalc's intuitive design will save you time on maintenance so you can get your products out the door sooner.

Once you purchase a license, you do not have to pay additional royalty fees.  And you can use the same license across various platforms.

The uCalc SDK comes with two additional APIs: a Transformer and a String Library, which advanced users are sure to benefit from and may eventually find even more useful than the math parser.  They are seamlessly integrated with the math parser and bundled together at no additional cost.

The complete financial DSL processing a multi-line script of deposits, withdrawals, and interest calculation.

ID: 1331

				
					using uCalcSoftware;

var uc = new uCalc();
// 1. Initialize the account balance
uc.DefineVariable("balance = 0.0");

// 2. Define the DSL rules on the expression transformer
var t = uc.ExpressionTransformer;
t.FromTo("DEPOSIT {@Number:amount}", "balance = balance + {amount}");
t.FromTo("WITHDRAW {@Number:amount}", "balance = balance - {amount}");
t.FromTo("INTEREST {@Number:rate}", "balance = balance * (1 + {rate} / 100.0)");

// 3. Define the multi-line transaction script
var script = """

DEPOSIT 1000.00
WITHDRAW 50.75
INTEREST 0.5
WITHDRAW 200.00

""";

Console.WriteLine($"Initial Balance: {uc.Eval("balance")}");
Console.WriteLine("Processing script...");

// 4. Evaluate the entire script.
// Note: EvalStr returns the result of the LAST line.
// The intermediate lines modify the 'balance' variable.
uc.EvalStr(script);

// 5. Get the final balance
Console.WriteLine($"Final Balance: {uc.EvalStr("balance")}");
				
			
Initial Balance: 0
Processing script...
Final Balance: 753.99625
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   // 1. Initialize the account balance
   uc.DefineVariable("balance = 0.0");

   // 2. Define the DSL rules on the expression transformer
   auto t = uc.ExpressionTransformer();
   t.FromTo("DEPOSIT {@Number:amount}", "balance = balance + {amount}");
   t.FromTo("WITHDRAW {@Number:amount}", "balance = balance - {amount}");
   t.FromTo("INTEREST {@Number:rate}", "balance = balance * (1 + {rate} / 100.0)");

   // 3. Define the multi-line transaction script
   auto script = R"(
DEPOSIT 1000.00
WITHDRAW 50.75
INTEREST 0.5
WITHDRAW 200.00
)";

   cout << "Initial Balance: " << uc.Eval("balance") << endl;
   cout << "Processing script..." << endl;

   // 4. Evaluate the entire script.
   // Note: EvalStr returns the result of the LAST line.
   // The intermediate lines modify the 'balance' variable.
   uc.EvalStr(script);

   // 5. Get the final balance
   cout << "Final Balance: " << uc.EvalStr("balance") << endl;
}
				
			
Initial Balance: 0
Processing script...
Final Balance: 753.99625
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      '// 1. Initialize the account balance
      uc.DefineVariable("balance = 0.0")
      
      '// 2. Define the DSL rules on the expression transformer
      Dim t = uc.ExpressionTransformer
      t.FromTo("DEPOSIT {@Number:amount}", "balance = balance + {amount}")
      t.FromTo("WITHDRAW {@Number:amount}", "balance = balance - {amount}")
      t.FromTo("INTEREST {@Number:rate}", "balance = balance * (1 + {rate} / 100.0)")
      
      '// 3. Define the multi-line transaction script
      Dim script = "
DEPOSIT 1000.00
WITHDRAW 50.75
INTEREST 0.5
WITHDRAW 200.00
"
      
      Console.WriteLine($"Initial Balance: {uc.Eval("balance")}")
      Console.WriteLine("Processing script...")
      
      '// 4. Evaluate the entire script.
      '// Note: EvalStr returns the result of the LAST line.
      '// The intermediate lines modify the 'balance' variable.
      uc.EvalStr(script)
      
      '// 5. Get the final balance
      Console.WriteLine($"Final Balance: {uc.EvalStr("balance")}")
   End Sub
End Module
				
			
Initial Balance: 0
Processing script...
Final Balance: 753.99625

uCalc Fast Math Parser is just what you're looking for!

This is the tip of the iceberg

Hopefully, this page has given you a glimpse of what uCalc Fast Math Parser can do.  Read the documentation and browse through over 600 examples for more.

Performing a simple unit conversion from inches to centimeters using `{@Eval}`.

ID: 1217

				
					using uCalcSoftware;

var uc = new uCalc();
var t = new uCalc.Transformer();

// Capture a number followed by 'in' and convert it.
// Note: `len` is a string, so we must use Double(len) for the calculation.
t.FromTo("{@Number:len}in", "{@Eval: Double(len) * 2.54}cm");

Console.WriteLine(t.Transform("The board is 10in long."));
				
			
The board is 25.4cm long.
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   uCalc::Transformer t;

   // Capture a number followed by 'in' and convert it.
   // Note: `len` is a string, so we must use Double(len) for the calculation.
   t.FromTo("{@Number:len}in", "{@Eval: Double(len) * 2.54}cm");

   cout << t.Transform("The board is 10in long.") << endl;
}
				
			
The board is 25.4cm long.
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t As New uCalc.Transformer()
      
      '// Capture a number followed by 'in' and convert it.
      '// Note: `len` is a string, so we must use Double(len) for the calculation.
      t.FromTo("{@Number:len}in", "{@Eval: Double(len) * 2.54}cm")
      
      Console.WriteLine(t.Transform("The board is 10in long."))
   End Sub
End Module
				
			
The board is 25.4cm long.