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:
Resets a scalar variable to the default value for its data type.
This method does not return a value.
Resets a scalar variable to its default value based on its underlying data type. This is an in-place modification, meaning it directly alters the memory where the variable's value is stored.
Default values for common types include:
0"")false0+0iDataType.Reset?At first glance, this method might seem redundant. After all, you can achieve a similar result with a simple assignment:
csharp
// Using simple assignment
double x = 123.45;
x = 0;
However, DataType.Reset offers a distinct advantage in specific scenarios. It operates directly on the memory address of the value. This is particularly useful for:
Reset can be more efficient as it avoids the overhead associated with reassignment, especially for complex types that might involve memory deallocation and reallocation.Variable object itself.| Method | Syntax | Mechanism | Use Case |
|---|---|---|---|
| Assignment | MyVar = 0; | Assigns a new value. May involve memory deallocation/reallocation for complex types. | Everyday, general-purpose variable resets. Simple and readable. |
DataType.Reset | uc.DataTypeOf("double").Reset(MyVar.ValueAddr()); | Modifies the existing memory in-place to its default state. | High-performance scenarios, low-level memory manipulation, or when you only have a pointer to the value. |
ID: 88
using uCalcSoftware;
var uc = new uCalc();
var MyDbl = uc.DefineVariable("MyDbl = 123.456");
var MyStr = uc.DefineVariable("MyStr = 'Hello world!'");
var MyCplx = uc.DefineVariable("MyCplx = 3 + 4 * #i");
Console.WriteLine(uc.EvalStr("MyDbl"));
Console.WriteLine(uc.EvalStr("MyStr"));
Console.WriteLine(uc.EvalStr("MyCplx"));
uc.DataTypeOf("double").Reset(MyDbl.ValueAddr());
uc.DataTypeOf("string").Reset(MyStr.ValueAddr()); // empty string ""
uc.DataTypeOf("complex").Reset(MyCplx.ValueAddr());
Console.WriteLine(uc.EvalStr("MyDbl"));
Console.WriteLine(uc.EvalStr("MyStr"));
Console.WriteLine(uc.EvalStr("MyCplx"));
123.456
Hello world!
3+4i
0
0+0i using uCalcSoftware; var uc = new uCalc(); var MyDbl = uc.DefineVariable("MyDbl = 123.456"); var MyStr = uc.DefineVariable("MyStr = 'Hello world!'"); var MyCplx = uc.DefineVariable("MyCplx = 3 + 4 * #i"); Console.WriteLine(uc.EvalStr("MyDbl")); Console.WriteLine(uc.EvalStr("MyStr")); Console.WriteLine(uc.EvalStr("MyCplx")); uc.DataTypeOf("double").Reset(MyDbl.ValueAddr()); uc.DataTypeOf("string").Reset(MyStr.ValueAddr()); // empty string "" uc.DataTypeOf("complex").Reset(MyCplx.ValueAddr()); Console.WriteLine(uc.EvalStr("MyDbl")); Console.WriteLine(uc.EvalStr("MyStr")); Console.WriteLine(uc.EvalStr("MyCplx"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto MyDbl = uc.DefineVariable("MyDbl = 123.456");
auto MyStr = uc.DefineVariable("MyStr = 'Hello world!'");
auto MyCplx = uc.DefineVariable("MyCplx = 3 + 4 * #i");
cout << uc.EvalStr("MyDbl") << endl;
cout << uc.EvalStr("MyStr") << endl;
cout << uc.EvalStr("MyCplx") << endl;
uc.DataTypeOf("double").Reset(MyDbl.ValueAddr());
uc.DataTypeOf("string").Reset(MyStr.ValueAddr()); // empty string ""
uc.DataTypeOf("complex").Reset(MyCplx.ValueAddr());
cout << uc.EvalStr("MyDbl") << endl;
cout << uc.EvalStr("MyStr") << endl;
cout << uc.EvalStr("MyCplx") << endl;
}
123.456
Hello world!
3+4i
0
0+0i #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto MyDbl = uc.DefineVariable("MyDbl = 123.456"); auto MyStr = uc.DefineVariable("MyStr = 'Hello world!'"); auto MyCplx = uc.DefineVariable("MyCplx = 3 + 4 * #i"); cout << uc.EvalStr("MyDbl") << endl; cout << uc.EvalStr("MyStr") << endl; cout << uc.EvalStr("MyCplx") << endl; uc.DataTypeOf("double").Reset(MyDbl.ValueAddr()); uc.DataTypeOf("string").Reset(MyStr.ValueAddr()); // empty string "" uc.DataTypeOf("complex").Reset(MyCplx.ValueAddr()); cout << uc.EvalStr("MyDbl") << endl; cout << uc.EvalStr("MyStr") << endl; cout << uc.EvalStr("MyCplx") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim MyDbl = uc.DefineVariable("MyDbl = 123.456")
Dim MyStr = uc.DefineVariable("MyStr = 'Hello world!'")
Dim MyCplx = uc.DefineVariable("MyCplx = 3 + 4 * #i")
Console.WriteLine(uc.EvalStr("MyDbl"))
Console.WriteLine(uc.EvalStr("MyStr"))
Console.WriteLine(uc.EvalStr("MyCplx"))
uc.DataTypeOf("double").Reset(MyDbl.ValueAddr())
uc.DataTypeOf("string").Reset(MyStr.ValueAddr()) '// empty string ""
uc.DataTypeOf("complex").Reset(MyCplx.ValueAddr())
Console.WriteLine(uc.EvalStr("MyDbl"))
Console.WriteLine(uc.EvalStr("MyStr"))
Console.WriteLine(uc.EvalStr("MyCplx"))
End Sub
End Module
123.456
Hello world!
3+4i
0
0+0i Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim MyDbl = uc.DefineVariable("MyDbl = 123.456") Dim MyStr = uc.DefineVariable("MyStr = 'Hello world!'") Dim MyCplx = uc.DefineVariable("MyCplx = 3 + 4 * #i") Console.WriteLine(uc.EvalStr("MyDbl")) Console.WriteLine(uc.EvalStr("MyStr")) Console.WriteLine(uc.EvalStr("MyCplx")) uc.DataTypeOf("double").Reset(MyDbl.ValueAddr()) uc.DataTypeOf("string").Reset(MyStr.ValueAddr()) '// empty string "" uc.DataTypeOf("complex").Reset(MyCplx.ValueAddr()) Console.WriteLine(uc.EvalStr("MyDbl")) Console.WriteLine(uc.EvalStr("MyStr")) Console.WriteLine(uc.EvalStr("MyCplx")) End Sub End Module