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:
Retrieves a callback argument specifically as a double-precision floating-point number, with automatic type conversion.
The argument's value, converted to a double-precision floating-point number if necessary.
The ArgDbl method retrieves an argument passed to a callback function, ensuring the value is returned as a double. It is a type-specific accessor that improves code clarity by making the expected data type explicit.
This method is functionally identical to its more generic counterpart, Arg. The Arg() method exists primarily for historical reasons, as double is the default numeric type in uCalc. Using ArgDbl is recommended when you specifically expect a floating-point number, as it makes your code more self-documenting.
A key feature of ArgDbl is its ability to perform automatic type conversion. If a function parameter was defined as a different numeric type (e.g., Int32, Boolean), and the callback retrieves it using ArgDbl, uCalc will safely convert the value to a double before returning it. This provides flexibility when a function needs to handle various numeric inputs.
In many frameworks, callback arguments are passed in a generic collection, like an object[] in C# or a std::vector<std::any> in C++. Accessing a value requires explicit casting and type checking:
// Typical C# approachdouble length = (double)args[0]; This approach is verbose and can lead to runtime InvalidCastException errors if the type is not what was expected.
uCalc's type-specific accessors like ArgDbl, ArgInt32, and ArgStr streamline this process. They handle the type conversion internally and provide a cleaner, more robust interface, reducing boilerplate code and the potential for casting errors.
ID: 84
using uCalcSoftware;
var uc = new uCalc();
static void MyArea(uCalc.Callback cb) {
var Length = cb.ArgDbl(1); // Same as cb.Arg(1);
var Width = cb.ArgDbl(2); // Same as cb.Arg(2);
cb.Return(Length * Width);
}
uc.DefineFunction("Area(x, y)", MyArea);
Console.WriteLine(uc.Eval("Area(3, 4)"));
12 using uCalcSoftware; var uc = new uCalc(); static void MyArea(uCalc.Callback cb) { var Length = cb.ArgDbl(1); // Same as cb.Arg(1); var Width = cb.ArgDbl(2); // Same as cb.Arg(2); cb.Return(Length * Width); } uc.DefineFunction("Area(x, y)", MyArea); Console.WriteLine(uc.Eval("Area(3, 4)"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
void ucalc_call MyArea(uCalcBase::Callback cb) {
auto Length = cb.ArgDbl(1); // Same as cb.Arg(1);
auto Width = cb.ArgDbl(2); // Same as cb.Arg(2);
cb.Return(Length * Width);
}
int main() {
uCalc uc;
uc.DefineFunction("Area(x, y)", MyArea);
cout << uc.Eval("Area(3, 4)") << endl;
}
12 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; void ucalc_call MyArea(uCalcBase::Callback cb) { auto Length = cb.ArgDbl(1); // Same as cb.Arg(1); auto Width = cb.ArgDbl(2); // Same as cb.Arg(2); cb.Return(Length * Width); } int main() { uCalc uc; uc.DefineFunction("Area(x, y)", MyArea); cout << uc.Eval("Area(3, 4)") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub MyArea(ByVal cb As uCalc.Callback)
Dim Length = cb.ArgDbl(1) '// Same as cb.Arg(1);
Dim Width = cb.ArgDbl(2) '// Same as cb.Arg(2);
cb.Return(Length * Width)
End Sub
Public Sub Main()
Dim uc As New uCalc()
uc.DefineFunction("Area(x, y)", AddressOf MyArea)
Console.WriteLine(uc.Eval("Area(3, 4)"))
End Sub
End Module
12 Imports System Imports uCalcSoftware Public Module Program Public Sub MyArea(ByVal cb As uCalc.Callback) Dim Length = cb.ArgDbl(1) '// Same as cb.Arg(1); Dim Width = cb.ArgDbl(2) '// Same as cb.Arg(2); cb.Return(Length * Width) End Sub Public Sub Main() Dim uc As New uCalc() uc.DefineFunction("Area(x, y)", AddressOf MyArea) Console.WriteLine(uc.Eval("Area(3, 4)")) End Sub End Module