mirror of
https://github.com/mehah/otclient
synced 2026-08-15 16:29:06 -04:00
17 lines
No EOL
265 B
Lua
17 lines
No EOL
265 B
Lua
Bit = {}
|
|
|
|
function Bit.bit(p)
|
|
return 2 ^ (p - 1)
|
|
end
|
|
|
|
function Bit.hasBit(x, p)
|
|
return x % (p + p) >= p
|
|
end
|
|
|
|
function Bit.setbit(x, p)
|
|
return Bit.hasBit(x, p) and x or x + p
|
|
end
|
|
|
|
function Bit.clearbit(x, p)
|
|
return Bit.hasBit(x, p) and x - p or x
|
|
end |