Bitwise
local Bitwise = require("Starlit/utils/Bitwise")
The Bitwise module defines some bitwise operation helper functions. These are generally faster than other implementations I’ve come across.
Functions
-
Bitwise.get(int:
integer
, pos:integer
) bit:boolean
Checks the value of a single bit within an integer.
- Parameters:
int (
integer
) – The integer.pos (
integer
) – Position of the bit, counting from the right, starting with 1.
- Returns:
bit (
boolean
) – The value of the bit.
-
Bitwise.set(int:
integer
, pos:integer
, value:boolean
) int:integer
Returns the passed integer int modified with the specified bit changed.
- Parameters:
int (
integer
) – The integer to modify.pos (
integer
) – The position of the bit to modify.boolean (
value
) – The value to set the bit to.
- Returns:
int (
integer
) – The modified integer.