Skip to content
Member Filters
Show Inherited
Show Protected
Show abstract
GR32_LowLevel🞂WrapPow2Function

WrapPow2

Fast bitwise wrap alternative for ranges where range length is a power of two.

Declarations ​

pascal
function WrapPow2(Value, Max: Integer): Integer; overload;
function WrapPow2(Value, Min, Max: Integer): Integer; overload;
Overload Details

Overload 1 ​

pascal
function WrapPow2(Value, Max: Integer): Integer; overload;

Wraps an integer value to range [0..Max] where Max+1 is a power of two.

ParameterTypeDescription
ValueIntegerInteger value to wrap.
MaxIntegerInclusive upper bound (where Max+1 is a power of 2, e.g. 3, 7, 15, 255).
TypeDescription
IntegerWrapped integer within range [0..Max].

Overload 2 ​

pascal
function WrapPow2(Value, Min, Max: Integer): Integer; overload;

Wraps an integer value to range [Min..Max] where Max-Min+1 is a power of two.

ParameterTypeDescription
ValueIntegerInteger value to wrap.
MinIntegerInclusive lower bound.
MaxIntegerInclusive upper bound (where Max-Min+1 is a power of 2).
TypeDescription
IntegerWrapped integer within range [Min..Max].

Description ​

WrapPow2 provides accelerated bitwise wrapping for power-of-two dimensions (e.g., textures of width/height 4, 8, 16, 32, 64, 128, 256, 512, 1024). It replaces division/modulo operations with fast bitwise AND masking (Value and Max).

See also ​