NAME ^

lib/bit.pir - bitwise operations library

DESCRIPTION ^

bit is a library for Lua 5.1 that provides bitwise operations on number.

See original on http://bitop.luajit.org/

bit.tobit (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.
bit.bnot (x)
Returns the bitwise not of its argument.
bit.band (x1 [,x2...])
bit.bor (x1 [,x2...])
bit.bxor (x1 [,x2...])
Returns either the bitwise or, bitwise and, or bitwise xor of all of its arguments. Note that more than two arguments are allowed.
bit.lshift (x, n)
bit.rshift (x, n)
bit.arshift (x, n)
Returns either the bitwise logical left-shift, bitwise logical right-shift, or bitwise arithmetic right-shift of its first argument by the number of bits given by the second argument.Logical shifts treat the first argument as an unsigned number and shift in 0-bits. Arithmetic right-shift treats the most-significant bit as a sign bit and replicates it.Only the lower 5 bits of the shift count are used (reduces to the range [0..31]).
bit.rol (x, n)
bit.ror (x, n)
Returns either the bitwise left rotation, or 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.Only the lower 5 bits of the rotate count are used (reduces to the range [0..31]).
bit.bswap (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.


parrot