uCalc API Version: 2.1.3-preview.2 Released: 6/17/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.

ReturnInt64

Method

Product: 

Fast Math Parser

Class: 

Callback

Returns a 64-bit integer value from a callback function to the evaluator.

Syntax

ReturnInt64(int64)

Parameters

value
int64
The 64-bit integer value to be returned.

Return

void

This method does not return a value; it communicates the result back to the uCalc engine via the callback context.

Remarks

The ReturnInt64 method is the primary mechanism for sending a 64-bit integer result from a native callback function back to the uCalc evaluation engine. When a custom function or operator is called within an expression, this method must be used within the callback to provide its output.

📦 Type-Specific Returns

This method is specifically for returning 64-bit integer values. uCalc provides a family of type-safe return methods for other data types. Using the correct method ensures data integrity and avoids unnecessary type conversions.

  • Return / ReturnDbl: For double-precision floating-point values.
  • ReturnStr: For string values.
  • ReturnBool: For boolean values.
  • ReturnInt32: For 32-bit integers.
  • ReturnInt64: For 64-bit integers (this method).

⚖️ Comparative Analysis

Unlike a native return statement in C# or C++, which is a language-level keyword, ReturnInt64() is a method call that interacts with the uCalc engine's internal state. It effectively places the provided value onto the evaluation stack, allowing the engine to continue processing the expression. This distinction is crucial: the callback function itself is typically void in the host language, and cb.ReturnInt64() is the designated channel for communicating results back to the parser.

Examples

Return and other type-specific versions of Return
				
					using uCalcSoftware;

var uc = new uCalc();

static void BooleanAnd(uCalc.Callback cb) {
   cb.ReturnBool(cb.ArgBool(1) && cb.ArgBool(2));
}
static void AddInt16(uCalc.Callback cb) {
   //C# promots Int16 to int for arithmetic hence (Int16) to convert it back
   cb.ReturnInt16((Int16)(cb.ArgInt16(1) + cb.ArgInt16(2)));

}
static void AddInt32(uCalc.Callback cb) {
   cb.ReturnInt32(cb.ArgInt32(1) + cb.ArgInt32(2));
}
static void AddInt64(uCalc.Callback cb) {
   cb.ReturnInt64(cb.ArgInt64(1) + cb.ArgInt64(2));
}


uc.DefineFunction("BooleanAnd(x As Bool, y As Bool) As Bool", BooleanAnd);
uc.DefineFunction("AddInt16(x As Int16, y As Int16) As Int16", AddInt16);
uc.DefineFunction("AddInt32(x As Int32, y As Int32) As Int32", AddInt32);
uc.DefineFunction("AddInt64(x As Int64, y As Int64) As Int64", AddInt64);

Console.WriteLine(uc.EvalStr("BooleanAnd(true, false)"));
Console.WriteLine(uc.EvalStr("AddInt16(5.2, 4.1)"));
Console.WriteLine(uc.EvalStr("AddInt32(2, 3)"));
Console.WriteLine(uc.EvalStr("AddInt64(10, 20)"));
				
			
false
9
5
30
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

void ucalc_call BooleanAnd(uCalcBase::Callback cb) {
   cb.ReturnBool(cb.ArgBool(1) && cb.ArgBool(2));
}
void ucalc_call AddInt16(uCalcBase::Callback cb) {
   
   cb.ReturnInt16(cb.ArgInt16(1) + cb.ArgInt16(2));
}
void ucalc_call AddInt32(uCalcBase::Callback cb) {
   cb.ReturnInt32(cb.ArgInt32(1) + cb.ArgInt32(2));
}
void ucalc_call AddInt64(uCalcBase::Callback cb) {
   cb.ReturnInt64(cb.ArgInt64(1) + cb.ArgInt64(2));
}
int main() {
   uCalc uc;

   uc.DefineFunction("BooleanAnd(x As Bool, y As Bool) As Bool", BooleanAnd);
   uc.DefineFunction("AddInt16(x As Int16, y As Int16) As Int16", AddInt16);
   uc.DefineFunction("AddInt32(x As Int32, y As Int32) As Int32", AddInt32);
   uc.DefineFunction("AddInt64(x As Int64, y As Int64) As Int64", AddInt64);

   cout << uc.EvalStr("BooleanAnd(true, false)") << endl;
   cout << uc.EvalStr("AddInt16(5.2, 4.1)") << endl;
   cout << uc.EvalStr("AddInt32(2, 3)") << endl;
   cout << uc.EvalStr("AddInt64(10, 20)") << endl;
}
				
			
false
9
5
30
				
					Imports System
Imports uCalcSoftware
Public Module Program
   
   Public Sub BooleanAnd(ByVal cb As uCalc.Callback)
      cb.ReturnBool(cb.ArgBool(1) And cb.ArgBool(2))
   End Sub
   Public Sub AddInt16(ByVal cb As uCalc.Callback)
      
      cb.ReturnInt16(cb.ArgInt16(1) + cb.ArgInt16(2))
   End Sub
   Public Sub AddInt32(ByVal cb As uCalc.Callback)
      cb.ReturnInt32(cb.ArgInt32(1) + cb.ArgInt32(2))
   End Sub
   Public Sub AddInt64(ByVal cb As uCalc.Callback)
      cb.ReturnInt64(cb.ArgInt64(1) + cb.ArgInt64(2))
   End Sub
   Public Sub Main()
      Dim uc As New uCalc()
      
      uc.DefineFunction("BooleanAnd(x As Bool, y As Bool) As Bool", AddressOf BooleanAnd)
      uc.DefineFunction("AddInt16(x As Int16, y As Int16) As Int16", AddressOf AddInt16)
      uc.DefineFunction("AddInt32(x As Int32, y As Int32) As Int32", AddressOf AddInt32)
      uc.DefineFunction("AddInt64(x As Int64, y As Int64) As Int64", AddressOf AddInt64)
      
      Console.WriteLine(uc.EvalStr("BooleanAnd(true, false)"))
      Console.WriteLine(uc.EvalStr("AddInt16(5.2, 4.1)"))
      Console.WriteLine(uc.EvalStr("AddInt32(2, 3)"))
      Console.WriteLine(uc.EvalStr("AddInt64(10, 20)"))
   End Sub
End Module
				
			
false
9
5
30