uCalc API Version: 5.7.0-preview.1 Released: 7/30/2026
Warning
uCalc API Preview Release Notice:This preview documentation describes the intended behavior of the API. It is not fully accurate or complete.The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.Use of the preview version in your production code is not recommended.
Product:Â
Class:Â
Rapidly evaluates a pre-parsed expression, optimized specifically for double-precision floating-point results.
The double-precision floating-point result of the expression. Returns an undefined value if the expression does not yield a double.
The EvaluateDbl method evaluates a pre-parsed expression, optimized specifically for performance-critical scenarios that return a double-precision floating-point value. It is the type-strict counterpart to the more flexible Evaluate method.
This method is a key component of uCalc's two-step evaluation model:
EvaluateDbl() repeatedly on the Expression object, which is significantly faster than re-parsing the string each time with Eval().EvaluateDbl is designed for speed and requires that the parsed expression's result is a double.
3.14 * r^2.Int32 or Boolean) or a non-numeric type (String, Complex). No conversion is attempted, and no error is raised.Use the general-purpose Evaluate() method if your expression might return other numeric types, as it will handle the conversion to double automatically.
EvaluateDbl vs. Evaluate| Feature | EvaluateDbl() | Evaluate() |
|---|---|---|
| Performance | 🟢 Highest. Optimized for direct double evaluation. | 🟡 High. Slightly slower due to type-checking and potential conversion logic. |
| Type Safety | 🔴 Strict. Only works for expressions returning double. | 🟢 Flexible. Handles any numeric type by converting it to double. |
| Use Case | Ideal for high-speed loops in scientific or financial calculations where the return type is known to be double. | General-purpose numeric evaluation where flexibility is more important than maximum performance. |
In many programming environments, evaluating a string expression is a single, monolithic operation. uCalc separates parsing from evaluation, which mirrors how compilers work and offers significant performance advantages.
eval() in Scripting Languages: Functions like JavaScript's eval() re-parse the string on every call, making them inefficient for loops.DataTable.Compute: This common .NET workaround is notoriously slow because it involves significant overhead for each calculation.EvaluateDbl are nearly as fast as calling a native, compiled function, but with the full dynamic flexibility of a runtime engine.This model allows uCalc to achieve performance levels suitable for real-time simulations and data processing tasks that would be too slow for traditional script evaluators.
ID: 96
using uCalcSoftware;
var uc = new uCalc();
// The int return value type in MyExprB is converted to
// Double with .Evaluate(), but not with .EvaluateDbl()
var MyExprA = uc.Parse("3.2 + 5.2");
var MyExprB = uc.Parse("int(3.2 + 5.2)");
Console.WriteLine(MyExprA.Evaluate());
Console.WriteLine(MyExprA.EvaluateDbl() == 8.4);
Console.WriteLine(MyExprB.Evaluate());
Console.WriteLine(MyExprB.EvaluateDbl() == 8);
8.4
True
8
False using uCalcSoftware; var uc = new uCalc(); // The int return value type in MyExprB is converted to // Double with .Evaluate(), but not with .EvaluateDbl() var MyExprA = uc.Parse("3.2 + 5.2"); var MyExprB = uc.Parse("int(3.2 + 5.2)"); Console.WriteLine(MyExprA.Evaluate()); Console.WriteLine(MyExprA.EvaluateDbl() == 8.4); Console.WriteLine(MyExprB.Evaluate()); Console.WriteLine(MyExprB.EvaluateDbl() == 8);
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
#define tf(IsTrue) ((IsTrue) ? "True" : "False")
int main() {
uCalc uc;
// The int return value type in MyExprB is converted to
// Double with .Evaluate(), but not with .EvaluateDbl()
auto MyExprA = uc.Parse("3.2 + 5.2");
auto MyExprB = uc.Parse("int(3.2 + 5.2)");
cout << MyExprA.Evaluate() << endl;
cout << tf(MyExprA.EvaluateDbl() == 8.4) << endl;
cout << MyExprB.Evaluate() << endl;
cout << tf(MyExprB.EvaluateDbl() == 8) << endl;
}
8.4
True
8
False #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; #define tf(IsTrue) ((IsTrue) ? "True" : "False") int main() { uCalc uc; // The int return value type in MyExprB is converted to // Double with .Evaluate(), but not with .EvaluateDbl() auto MyExprA = uc.Parse("3.2 + 5.2"); auto MyExprB = uc.Parse("int(3.2 + 5.2)"); cout << MyExprA.Evaluate() << endl; cout << tf(MyExprA.EvaluateDbl() == 8.4) << endl; cout << MyExprB.Evaluate() << endl; cout << tf(MyExprB.EvaluateDbl() == 8) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// The int return value type in MyExprB is converted to
'// Double with .Evaluate(), but not with .EvaluateDbl()
Dim MyExprA = uc.Parse("3.2 + 5.2")
Dim MyExprB = uc.Parse("int(3.2 + 5.2)")
Console.WriteLine(MyExprA.Evaluate())
Console.WriteLine(MyExprA.EvaluateDbl() = 8.4)
Console.WriteLine(MyExprB.Evaluate())
Console.WriteLine(MyExprB.EvaluateDbl() = 8)
End Sub
End Module
8.4
True
8
False Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// The int return value type in MyExprB is converted to '// Double with .Evaluate(), but not with .EvaluateDbl() Dim MyExprA = uc.Parse("3.2 + 5.2") Dim MyExprB = uc.Parse("int(3.2 + 5.2)") Console.WriteLine(MyExprA.Evaluate()) Console.WriteLine(MyExprA.EvaluateDbl() = 8.4) Console.WriteLine(MyExprB.Evaluate()) Console.WriteLine(MyExprB.EvaluateDbl() = 8) End Sub End Module