LuaSTG-x Core API
|
Public Member Functions | |
static function | arshift (local x, local n) |
static function | band (local x1, local x2) |
static function | bnot (local x) |
static function | bor (local x1, local x2) |
static function | bswap (local x) |
static function | bxor (local x1, local x2) |
static function | lshift (local x, local n) |
static function | rol (local x, local n) |
static function | ror (local x, local n) |
static function | rshift (local x, local n) |
static function | tobit (local x) |
static function | tohex (local x, local n) |
Lua BitOp is a C extension module for Lua 5.1/5.2 which adds bitwise operations on numbers.
Returns the bitwise arithmetic right-shift of its first argument by the number of bits given by the second argument.
Returns either the bitwise and of all of its arguments. Note that more than two arguments are allowed.
Returns either the bitwise or of all of its arguments. Note that more than two arguments are allowed.
Swaps the bytes of its argument and returns it. This can be used to convert little-endian 32 bit numbers to big-endian 32 bit numbers or vice versa.
Returns either the bitwise xor of all of its arguments. Note that more than two arguments are allowed.
Returns the bitwise logical left-shift of its first argument by the number of bits given by the second argument.
Returns the bitwise left rotation of its first argument by the number of bits given by the second argument. Bits shifted out on one side are shifted back in on the other side.
Returns the bitwise right rotation of its first argument by the number of bits given by the second argument. Bits shifted out on one side are shifted back in on the other side.
Returns the bitwise logical right-shift of its first argument by the number of bits given by the second argument.
Normalizes a number to the numeric range for bit operations and returns it. This function is usually not needed since all bit operations already normalize all of their input arguments.
Converts its first argument to a hex string. The number of hex digits is given by the absolute value of the optional second argument. Positive numbers between 1 and 8 generate lowercase hex digits. Negative numbers generate uppercase hex digits. Only the least-significant 4*|n| bits are used. The default is to generate 8 lowercase hex digits.