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.
Product:
Class:
Performs a direct memory read of a variable's value, reinterpreting the first 16 bits as a signed integer.
Returns a 16-bit integer
The ValueInt16() method is a low-level, high-performance accessor that reads the value of a uCalc Item by interpreting its first 16 bits (2 bytes) of memory as a signed integer (short in C#).
This method does not perform type checking or conversion. It is a direct memory operation.
Int16, it correctly returns the variable's value.Int32: It will read the lower 16 bits of the 32-bit integer.Double: It will read the first 2 bytes of the 8-byte floating-point representation, resulting in a value that is not numerically related to the original double.String: It will read the first 2 bytes of the internal string object's memory (which could be part of a pointer or length field), leading to unpredictable results.For safe, type-converting access, use ValueStr() and parse the resulting string.
This method's behavior is analogous to low-level type punning operations in other languages, designed for performance at the cost of safety.
reinterpret_cast: Functionally similar to casting a pointer of one type to a short* and dereferencing it. It's a powerful tool for performance-critical code but bypasses the type system.BitConverter.ToInt16: Similar to taking the first two bytes from another type's byte array and converting them to a short.Use this method only when performance is critical and the data type is guaranteed.