LuaSTG-x Core API
bit Class Reference

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)
 

Detailed Description

Lua BitOp is a C extension module for Lua 5.1/5.2 which adds bitwise operations on numbers.

Member Function Documentation

◆ arshift()

static function arshift ( local  x,
local  n 
)

Returns the bitwise arithmetic right-shift of its first argument by the number of bits given by the second argument.

◆ band()

static function band ( local  x1,
local  x2 
)

Returns either the bitwise and of all of its arguments. Note that more than two arguments are allowed.

◆ bnot()

static function bnot ( local  x)

Returns the bitwise not of its argument.

◆ bor()

static function bor ( local  x1,
local  x2 
)

Returns either the bitwise or of all of its arguments. Note that more than two arguments are allowed.

◆ bswap()

static function bswap ( local  x)

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.

◆ bxor()

static function bxor ( local  x1,
local  x2 
)

Returns either the bitwise xor of all of its arguments. Note that more than two arguments are allowed.

◆ lshift()

static function lshift ( local  x,
local  n 
)

Returns the bitwise logical left-shift of its first argument by the number of bits given by the second argument.

◆ rol()

static function rol ( local  x,
local  n 
)

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.

◆ ror()

static function ror ( local  x,
local  n 
)

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.

◆ rshift()

static function rshift ( local  x,
local  n 
)

Returns the bitwise logical right-shift of its first argument by the number of bits given by the second argument.

◆ tobit()

static function tobit ( local  x)

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.

◆ tohex()

static function tohex ( local  x,
local  n 
)

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.


The documentation for this class was generated from the following file: