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.

Reset

Method

Product: 

Class: 

Resets a scalar variable to the default value for its data type.

Syntax

Reset(POINTER)

Parameters

valuePointer
POINTER
A pointer to the scalar variable's value that should be reset.

Return

void

This method does not return a value.

Remarks

🎯 Function

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:

  • Numeric (double, int, etc.): 0
  • String: An empty string ("")
  • Boolean: false
  • Complex: 0+0i

🤔 Why Use DataType.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:

  1. Performance-Critical Loops: In tight loops where you frequently need to reset a variable, Reset can be more efficient as it avoids the overhead associated with reassignment, especially for complex types that might involve memory deallocation and reallocation.
  2. Low-Level Manipulation: When interfacing with code that passes data by reference or pointer, this method provides a direct way to clear the underlying data without needing a reference to the Variable object itself.

⚖️ Comparative Analysis

MethodSyntaxMechanismUse Case
AssignmentMyVar = 0;Assigns a new value. May involve memory deallocation/reallocation for complex types.Everyday, general-purpose variable resets. Simple and readable.
DataType.Resetuc.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.

Examples

Data type Reset

ID: 88

See: Reset
				
					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
				
					#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;


}
				
			
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
				
			
123.456
Hello world!
3+4i
0

0+0i