require "bit"
local function setBitFlags(bit, bitFlag, bitValue)
if bit.band(bit, flag) == flag then
else
end
end
-- and操作
-- 00000001 1
--[[
255 11111111
129 10000000
]]
local i = 129
print("bxor : ", bit.bxor(i, 128)) -- 置0
print("bxor : ", bit.bxor(i, 128))
i = 129
print("bnot : ", bit.bnot(i, 128))
print("bnot : ", bit.bnot(i, 128))
i = 128
print("bor : ", bit.bor(i, 128)) -- 置1
print("bor : ", bit.bor(i, 2))
Lua的位运算
最新推荐文章于 2024-03-07 09:51:52 发布