Lua的位运算

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,lua)