uCalc API Version: 2.1.3-preview.2 Released: 6/16/2026

Warning

uCalc API Preview Release Notice:The documentation describes the intended behavior of the API. The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.

Reset

Method

Product: 

Fast Math Parser

Class: 

DataType

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:

// Using simple assignmentdouble 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
				
					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