ByteSize = [int]

Property

Gets the size, in bytes, that a single value of this data type occupies in memory.

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.

Remarks

The ByteSize method returns the number of bytes a single unit of this data type occupies in memory. This is essential for understanding memory layout, performing serialization, or interfacing with external native code that requires explicit size information.

Common Data Type Sizes

The following table shows the byte sizes for some of uCalc's common built-in types on a typical 64-bit system.

Data Type NameBuiltInType Enum MemberByteSizeNotes
32-bit IntegerInteger_324Standard integer size.
64-bit IntegerInteger_648Long integer.
DoubleFloat_Double8Default floating-point type.
BooleanBoolean4Typically aligned to an integer.
StringString8Size of the handle/pointer to the string data, not the character length.
PointerPointer8Size of a memory address.

Note on Dynamic Types: For compound or variable-length types like String, ByteSize returns the size of the internal handle or pointer, not the size of the allocated content. To get the number of characters in a string, use the Length() function.

⚖️ Comparative Analysis

  • vs. C++/C# sizeof(T): In C++ and C#, sizeof is a compile-time operator that returns the size of a type. uCalc's ByteSize() is a runtime method. This means you can dynamically query the size of a data type whose identity might not be known until the program is running, which is a key advantage for scripting and dynamic environments.

  • Utility: ByteSize is particularly useful when working with arrays or when binding uCalc variables to structured memory buffers in the host application. It allows you to perform pointer arithmetic and calculate memory offsets correctly based on uCalc's internal type system.

Examples