Documentation/Reference

Unsigned numbers and bit operations

BYTE, UINT32 and UINT64 are distinct static types with ranges 0..255, 0..4,294,967,295 and 0..18,446,744,073,709,551,615. Packed lists use one, four and eight bytes per element respectively. Choose packed BYTE data for binary I/O; spare reserved capacity is never initialized content.

Hexadecimal &H, binary &B and octal &O literals have UINT64 type. Decimal whole literals retain INTEGER type. There are no implicit mixed numeric conversions. BYTE/UINT32/UINT64 constructors check range with the ordinary fatal policy. CBYTE/CUINT32/CUINT64 supply supported recoverable INTEGER/UINT64 conversions through NumericError. CINT(UINT64) checks signed range; CINT of BYTE/UINT32 is infallible. CDBL converts to binary64 with its normal rounding.

Operations Behavior
BitAnd, BitOr, BitXor, BitNot UINT64 bitwise operations
ShiftLeft, ShiftRight Shift UINT64 bits; right shift fills with zeros
RotateLeft, RotateRight Rotate within a UINT64 word
LeadingZeros, TrailingZeros, BitCount INTEGER counts; zero has 64 leading/trailing zeros
WrappingAdd/Subtract/Multiply Explicit arithmetic modulo 2^64
MultiplyHigh High half of a UINT64 multiplication
MultiplyWide WideProduct with High and Low UINT64 fields

Use matching UINT64 arguments for these named helpers, constructing them explicitly from narrower values when needed. Infix &, | and XOR also accept matching INTEGER/BYTE/UINT32/UINT64 operands directly. MultiplyWide’s record result is one successful value; it does not imply multiple-result syntax.

Shift/rotate counts are INTEGER in 0..63; invalid counts are fatal. Left shifts discard bits outside the word. UInt64Bits/UInt64FromBits reinterpret numerical bits between INTEGER and UINT64 without exposing addresses. UInt64Max returns the maximum unsigned value. Ordinary unsigned arithmetic checks overflow and division in its declared width; unary minus is rejected.

Lists, sets, dictionaries, optionals, records, arrays, sorting, hashing and formatting support unsigned scalars under their usual rules. Copies remain independent, resources keep their ownership restrictions, and an indexed BYREF or SWAP keeps its containing owner protected. Packed storage does not change those guarantees.

From the BASIL documentation. View source ↗

Find your way around BASIL

Type to search the manual.