bit32
bit32
This library is a back-ported feature from Lua 5.2 which provides functions to perform bitwise operations.
| number bit32.arshift ( number x, number disp ) |
|
Returns the number This shift operation is what is called arithmetic shift. Vacant bits on the left are filled with copies of the higher bit of |
| number bit32.band ( Tuple numbers ) |
|
Returns the bitwise and of its operands. |
| number bit32.bnot ( number x ) |
|
Returns the bitwise negation of assert(bit32.bnot(x) == (-1 - x) % 2^32) |
| number bit32.bor ( Tuple numbers ) |
|
Returns the bitwise or of its operands. |
| boolean bit32.btest ( Tuple numbers ) |
|
Returns a boolean signalling whether the bitwise and of its operands is different from zero. |
| number bit32.bxor ( Tuple numbers ) |
|
Returns the bitwise exclusive or of its operands. |
| number bit32.extract ( number n, number field, number width = 1 ) |
|
Returns the unsigned number formed by the bits |
| number bit32.replace ( number n, number v, number field, number width = 1 ) |
|
Returns a copy of |
| number bit32.lrotate ( number x, number disp ) |
|
Returns the number assert(bit32.lrotate(x, disp) == bit32.lrotate(x, disp % 32)) In particular, negative displacements rotate to the right. |
| number bit32.lshift ( number x, number disp ) |
|
Returns the number For positive displacements, the following equality holds: assert(bit32.lshift(b, disp) == (b * 2^disp) % 2^32) |
| number bit32.rrotate ( number x, number disp ) |
|
Returns the number For any valid displacement, the following identity holds: assert(bit32.rrotate(x, disp) == bit32.rrotate(x , disp % 32)) In particular, negative displacements rotate to the left. |
| number bit32.rshift ( number x, number disp ) |
|
Returns the number For positive displacements, the following equality holds: assert(bit32.rshift(b, disp) == math.floor(b % 2^32 / 2^disp)) This shift operation is what is called logical shift. |