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

ReflectPow2

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

Declarations ​

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

Overload 1 ​

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

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

ParameterTypeDescription
ValueIntegerInteger value to reflect.
MaxIntegerInclusive upper bound (where Max+1 is a power of 2).
TypeDescription
IntegerReflected integer coordinate in range [0..Max].

Overload 2 ​

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

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

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

Description ​

ReflectPow2 provides optimized power-of-two reflection by utilizing bitwise operations instead of division and modulo instructions.

See also ​