|
| 1 | +---@meta bit32 |
| 2 | + |
| 3 | +---@version 5.2 |
| 4 | +--- |
| 5 | +--- |
| 6 | +--- |
| 7 | +---[View documents](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32"]) |
| 8 | +--- |
| 9 | +---@class bit32lib |
| 10 | +bit32 = {} |
| 11 | + |
| 12 | +--- |
| 13 | +---Returns the number `x` shifted `disp` bits to the right. Negative displacements shift to the left. |
| 14 | +--- |
| 15 | +---This shift operation is what is called arithmetic shift. Vacant bits on the left are filled with copies of the higher bit of `x`; vacant bits on the right are filled with zeros. |
| 16 | +--- |
| 17 | +--- |
| 18 | +---[View documents](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.arshift"]) |
| 19 | +--- |
| 20 | +---@param x integer |
| 21 | +---@param disp integer |
| 22 | +---@return integer |
| 23 | +---@nodiscard |
| 24 | +function bit32.arshift(x, disp) end |
| 25 | + |
| 26 | +--- |
| 27 | +---Returns the bitwise *and* of its operands. |
| 28 | +--- |
| 29 | +---[View documents](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.band"]) |
| 30 | +--- |
| 31 | +---@return integer |
| 32 | +---@nodiscard |
| 33 | +function bit32.band(...) end |
| 34 | + |
| 35 | +--- |
| 36 | +---Returns the bitwise negation of `x`. |
| 37 | +--- |
| 38 | +---```lua |
| 39 | +---assert(bit32.bnot(x) == |
| 40 | +---(-1 - x) % 2^32) |
| 41 | +---``` |
| 42 | +--- |
| 43 | +--- |
| 44 | +---[View documents](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.bnot"]) |
| 45 | +--- |
| 46 | +---@param x integer |
| 47 | +---@return integer |
| 48 | +---@nodiscard |
| 49 | +function bit32.bnot(x) end |
| 50 | + |
| 51 | +--- |
| 52 | +---Returns the bitwise *or* of its operands. |
| 53 | +--- |
| 54 | +---[View documents](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.bor"]) |
| 55 | +--- |
| 56 | +---@return integer |
| 57 | +---@nodiscard |
| 58 | +function bit32.bor(...) end |
| 59 | + |
| 60 | +--- |
| 61 | +---Returns a boolean signaling whether the bitwise *and* of its operands is different from zero. |
| 62 | +--- |
| 63 | +---[View documents](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.btest"]) |
| 64 | +--- |
| 65 | +---@return boolean |
| 66 | +---@nodiscard |
| 67 | +function bit32.btest(...) end |
| 68 | + |
| 69 | +--- |
| 70 | +---Returns the bitwise *exclusive or* of its operands. |
| 71 | +--- |
| 72 | +---[View documents](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.bxor"]) |
| 73 | +--- |
| 74 | +---@return integer |
| 75 | +---@nodiscard |
| 76 | +function bit32.bxor(...) end |
| 77 | + |
| 78 | +--- |
| 79 | +---Returns the unsigned number formed by the bits `field` to `field + width - 1` from `n`. |
| 80 | +--- |
| 81 | +---[View documents](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.extract"]) |
| 82 | +--- |
| 83 | +---@param n integer |
| 84 | +---@param field integer |
| 85 | +---@param width? integer |
| 86 | +---@return integer |
| 87 | +---@nodiscard |
| 88 | +function bit32.extract(n, field, width) end |
| 89 | + |
| 90 | +--- |
| 91 | +---Returns a copy of `n` with the bits `field` to `field + width - 1` replaced by the value `v` . |
| 92 | +--- |
| 93 | +---[View documents](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.replace"]) |
| 94 | +--- |
| 95 | +---@param n integer |
| 96 | +---@param v integer |
| 97 | +---@param field integer |
| 98 | +---@param width? integer |
| 99 | +---@nodiscard |
| 100 | +function bit32.replace(n, v, field, width) end |
| 101 | + |
| 102 | +--- |
| 103 | +---Returns the number `x` rotated `disp` bits to the left. Negative displacements rotate to the right. |
| 104 | +--- |
| 105 | +---[View documents](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.lrotate"]) |
| 106 | +--- |
| 107 | +---@param x integer |
| 108 | +---@param distp integer |
| 109 | +---@return integer |
| 110 | +---@nodiscard |
| 111 | +function bit32.lrotate(x, distp) end |
| 112 | + |
| 113 | +--- |
| 114 | +---Returns the number `x` shifted `disp` bits to the left. Negative displacements shift to the right. In any direction, vacant bits are filled with zeros. |
| 115 | +--- |
| 116 | +---```lua |
| 117 | +---assert(bit32.lshift(b, disp) == |
| 118 | +---(b * 2^disp) % 2^32) |
| 119 | +---``` |
| 120 | +--- |
| 121 | +--- |
| 122 | +---[View documents](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.lshift"]) |
| 123 | +--- |
| 124 | +---@param x integer |
| 125 | +---@param distp integer |
| 126 | +---@return integer |
| 127 | +---@nodiscard |
| 128 | +function bit32.lshift(x, distp) end |
| 129 | + |
| 130 | +--- |
| 131 | +---Returns the number `x` rotated `disp` bits to the right. Negative displacements rotate to the left. |
| 132 | +--- |
| 133 | +---[View documents](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.rrotate"]) |
| 134 | +--- |
| 135 | +---@param x integer |
| 136 | +---@param distp integer |
| 137 | +---@return integer |
| 138 | +---@nodiscard |
| 139 | +function bit32.rrotate(x, distp) end |
| 140 | + |
| 141 | +--- |
| 142 | +---Returns the number `x` shifted `disp` bits to the right. Negative displacements shift to the left. In any direction, vacant bits are filled with zeros. |
| 143 | +--- |
| 144 | +---```lua |
| 145 | +---assert(bit32.rshift(b, disp) == |
| 146 | +---math.floor(b % 2^32 / 2^disp)) |
| 147 | +---``` |
| 148 | +--- |
| 149 | +--- |
| 150 | +---[View documents](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.rshift"]) |
| 151 | +--- |
| 152 | +---@param x integer |
| 153 | +---@param distp integer |
| 154 | +---@return integer |
| 155 | +---@nodiscard |
| 156 | +function bit32.rshift(x, distp) end |
| 157 | + |
| 158 | +return bit32 |
0 commit comments