Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
20
Task/Bitwise-operations/Pluto/bitwise-operations.pluto
Normal file
20
Task/Bitwise-operations/Pluto/bitwise-operations.pluto
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
-- Rotate left and right are not built-in but we use the
|
||||
-- same 32-bit substitutes as in the Lua 5.3+ example.
|
||||
local function rl(x, y) return ((x << y) & 0xffffffff) | (x >> (32 - y)) end
|
||||
|
||||
local function rr(x, y) return (x >> y) | ((x << (32 - y)) & 0xffffffff) end
|
||||
|
||||
local function bitwise(x, y)
|
||||
print($" x = {x}")
|
||||
print($" y = {y}")
|
||||
print($" x & y = {x & y}")
|
||||
print($" x | y = {x | y}")
|
||||
print($" x ~ y = {x ~ y}")
|
||||
print($"~x = {~x}")
|
||||
print($" x << y = {x << y}")
|
||||
print($" x >> y = {x >> y}")
|
||||
print($" x rl y = {rl(x, y)}")
|
||||
print($" x rr y = {rr(x, y)}")
|
||||
end
|
||||
|
||||
bitwise(10, 2)
|
||||
Loading…
Add table
Add a link
Reference in a new issue