ValueInt64()

Method

Retrieves the 64-bit integer value from a uCalc variable.

Product: 

Class: 

Warning

uCalc API Preview Release Notice:The uCalc engine has successfully transitioned to modern cross-platform environments.The next phase envolves some structural changes, performance optimizations, and API refinements.The API is subject to breaking changes prior to the stable release. Please evaluate the preview version thoroughly before production use.

Syntax

ValueInt64()

Parameters

[None]

Return

int64

The 64-bit integer value of the variable.

Remarks

Retrieving 64-bit Integer Values

The ValueInt64() method provides a direct, type-safe way to retrieve the value of a uCalc variable defined as a 64-bit integer (Int64 or Int64u).

Core Usage

This method is the counterpart to the ValueInt64 setter. It is used to access the current value of a variable from the host application, typically after it has been manipulated by a uCalc expression or set programmatically.

using uCalcSoftware;

var uc = new uCalc();

// Define a 64-bit integer variable
var myId = uc.DefineVariable("myId As Int64");

// Set its value
myId.ValueInt64(9007199254740991);

// Retrieve its value using the type-safe getter
int64_t retrievedId = myId.ValueInt64();
Console.WriteLine($"Retrieved ID: {retrievedId}");

🆚 Comparative Analysis: Why Use a Type-Specific Getter?

While uCalc offers several ways to retrieve a variable's value, ValueInt64() is the best choice for 64-bit integers due to performance and data integrity.

  1. ValueInt64() (Type-Safe Getter - Recommended)

    • Pros: Fastest method, returns the exact binary value without conversion, and preserves the full precision of 64-bit integers.
    • Cons: Specific to one data type.
    • Best for: Performance-critical code and handling large numbers like timestamps, database IDs, or financial calculations.
  2. Value() (Generic Getter - Potential Precision Loss)

    • This method always returns a double. While convenient, a double only has about 15-17 decimal digits of precision. A 64-bit integer can have up to 19 digits. Using Value() on large Int64 values will result in precision loss.
    • Best for: General-purpose numeric retrieval where maximum precision is not critical.
  3. ValueStr() (String-Based Getter)

    • This method returns the value as a string. It preserves precision but is slower due to the overhead of converting the number to a string and subsequent parsing if you need to use it as a number in your host application.
    • Best for: Displaying values or when a string representation is the desired final format.

In summary, always use ValueInt64() to retrieve Int64 or Int64u variables to guarantee both speed and data integrity.

Examples

This page last modified on: 

8/21/2026