UInteger
 
Standard data type: 32-bit or 64-bit unsigned, same size as SizeOf(Any Ptr).
Equivalent to Unsigned Integer.

Syntax

Dim variable As UInteger
Dim variable As UInteger<bits>

Parameters

bits
A numeric constant expression indicating the size in bits of unsigned integer desired. The values allowed are 8, 16, 32, 64 or 128.

Description

32-bit or 64-bit unsigned whole-number data type, depending on the platform.

If an explicit bit size is given, the data type uses the requested unsigned integer width. UInteger<128> holds values from 0 through 2^128-1. The selected data type is UByte for UInteger<8>, UShort for UInteger<16>, ULong for UInteger<32> and ULongInt for UInteger<64>. UInteger<128> is a distinct 16-byte scalar type.

LLVM emits native i128 arithmetic and bitwise operations; ABS and SGN use the two-word runtime helper. On 32-bit targets, LLVM also uses runtime helpers for conversions between floating-point values and 128-bit integers. GCC and Clang use native `int128` on targets that support it, with ABS and SGN using that same helper. On 32-bit targets, they use a 16-byte aligned two-word type and lower arithmetic through the runtime. C interop must use that structure layout; a native `int128` declaration is compatible only when the compiler supports it and uses a matching ABI.

On 32-bit Windows, the GAS backend keeps the four-byte stack ABI for local variables. UDT field offsets still use 16-byte alignment, but C code receiving a pointer to such a local must accept its four-byte alignment. The runtime helpers accept unaligned storage.

The native GAS and GAS64 backends lower arithmetic through the runtime library. GAS32 passes 128-bit arguments as 16-byte stack copies and returns values through a hidden result pointer, matching the i386 ABI for the aligned two-word C structure. GAS64 uses the SysV two-register ABI where available and stack arguments when those registers are exhausted. The GAS64 non-SysV path passes the 16-byte value through a caller-owned copy and returns through a hidden result pointer.

Example

#ifdef __FB_64BIT__
    Dim x As UInteger = 0
    Dim y As UInteger = &HFFFFFFFFFFFFFFFF
    Print "UInteger Range = "; x; " to "; y
#else
    Dim x As UInteger = 0
    Dim y As UInteger = &HFFFFFFFF
    Print "UInteger Range = "; x; " to "; y
#endif


Dialect Differences

  • Not available in the -lang qb dialect unless referenced with the alias __Uinteger.

Differences from QB

  • New to FreeBASIC

See also