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.

EvaluateVoid

Method

Product: 

Fast Math Parser

Class: 

Expression

Evaluates the expression and returns a native pointer to the result's memory location.

Syntax

EvaluateVoid()

Parameters

[None]

Return

IntPtr

An IntPtr representing the memory address of the evaluation result. The data at this address is valid only until the next evaluation within the same uCalc instance.

Remarks

This method is an advanced alternative to Evaluate. Instead of returning a copy of the result, it returns a direct native pointer to the internal memory where the result is stored.

🎯 Primary Use Case

🔧 Type Punning: It allows you to interpret the raw memory of a result as a different data type, without any conversion. This is useful for low-level tasks, such as treating the bits of an unsigned integer as a signed integer (as shown in the examples), or reinterpreting a floating-point number as an integer to examine its bit pattern. This is accomplished by passing the returned pointer to the ValueAt method with the desired target type.

⚠️ Pointer Validity and Lifetime

The returned pointer is ephemeral. It is only guaranteed to be valid until the next evaluation is performed on any expression within the same uCalc instance. uCalc reuses internal memory buffers for efficiency, so the memory location pointed to by the result of one evaluation will be overwritten by the result of the next.

Correct Usage:

var uc = new uCalc();// Get pointer and use it immediately.var resultPtr = myExpr.EvaluateVoid();var value = uc.ValueAt(resultPtr, "Int32"); // The value is now safely stored in a managed variable.

Incorrect Usage:

var uc = new uCalc();// Get pointer A.var ptrA = expr1.EvaluateVoid();// Another evaluation happens, invalidating ptrA.var ptrB = expr2.EvaluateVoid(); // This line is unsafe! ptrA may now point to the result of expr2.var value = uc.ValueAt(ptrA, "Int32"); 

Comparison to Native Languages

In C#, performing similar operations would typically require an unsafe code context. In C++, it would involve direct pointer manipulation. The EvaluateVoid and ValueAt combination provides a safer, cross-platform abstraction for these powerful low-level memory operations without leaving the managed environment.

Examples

Displaying an expression of unsigned byte as a signed byte by using a Pointer
				
					using uCalcSoftware;

var uc = new uCalc();
var VariableX = uc.DefineVariable("x As Int");
var ParsedExpr = uc.Parse("x + 125", "Int8u");

for (int x = 1; x <= 10; x++) {
   VariableX.ValueInt32(x);
   Console.WriteLine($"x = {x}  Int8 result = {uc.ValueAt(ParsedExpr.EvaluateVoid(), "Int8")}");
}

ParsedExpr.Release();
VariableX.Release();
				
			
x = 1  Int8 result = 126
x = 2  Int8 result = 127
x = 3  Int8 result = -128
x = 4  Int8 result = -127
x = 5  Int8 result = -126
x = 6  Int8 result = -125
x = 7  Int8 result = -124
x = 8  Int8 result = -123
x = 9  Int8 result = -122
x = 10  Int8 result = -121
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto VariableX = uc.DefineVariable("x As Int");
   auto ParsedExpr = uc.Parse("x + 125", "Int8u");

   for (int x = 1; x <= 10; x++) {
      VariableX.ValueInt32(x);
      cout << "x = " << x << "  Int8 result = " << uc.ValueAt(ParsedExpr.EvaluateVoid(), "Int8") << endl;
   }

   ParsedExpr.Release();
   VariableX.Release();
}
				
			
x = 1  Int8 result = 126
x = 2  Int8 result = 127
x = 3  Int8 result = -128
x = 4  Int8 result = -127
x = 5  Int8 result = -126
x = 6  Int8 result = -125
x = 7  Int8 result = -124
x = 8  Int8 result = -123
x = 9  Int8 result = -122
x = 10  Int8 result = -121
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim VariableX = uc.DefineVariable("x As Int")
      Dim ParsedExpr = uc.Parse("x + 125", "Int8u")
      
      For x  As Integer = 1 To 10
         VariableX.ValueInt32(x)
         Console.WriteLine($"x = {x}  Int8 result = {uc.ValueAt(ParsedExpr.EvaluateVoid(), "Int8")}")
      Next
      
      ParsedExpr.Release()
      VariableX.Release()
   End Sub
End Module
				
			
x = 1  Int8 result = 126
x = 2  Int8 result = 127
x = 3  Int8 result = -128
x = 4  Int8 result = -127
x = 5  Int8 result = -126
x = 6  Int8 result = -125
x = 7  Int8 result = -124
x = 8  Int8 result = -123
x = 9  Int8 result = -122
x = 10  Int8 result = -121