Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 47 additions & 11 deletions lua/entities/gmod_wire_expression2/core/bitwise.lua
Original file line number Diff line number Diff line change
@@ -1,47 +1,83 @@
-- By asiekierka, 2009 --
--Non-luabit XOR by TomyLobo--

__e2setcost(2)

local bit = bit

e2function number bAnd(a, b)
return bit.band(a, b)
end

e2function number bOr(a, b)
return bit.bor(a, b)
end

e2function number bXor(a, b)
return bit.bxor(a, b)
end

e2function number bShar(a, b)
return bit.arshift(a, b)
end

e2function number bShr(a, b)
return bit.rshift(a, b)
end

e2function number bShl(a, b)
return bit.lshift(a, b)
end

e2function number bRol(a, b)
return bit.rol(a, b)
end

e2function number bRor(a, b)
return bit.ror(a, b)
end

e2function number bSwap(n)
return bit.bswap(n)
end

e2function number bToBit(n)
return bit.tobit(n)
end

e2function number bNot(n)
return bit.bnot(n)
end
e2function number bNot(n,bits)

e2function number bNot(n, bits)
if bits >= 32 or bits < 1 then
return (-1)-n
return -1 - n
else
return (math.pow(2,bits)-1)-n
return 2 ^ bits - 1 - n
end
end

e2function string bToHex(n)
return bit.tohex(n)
end

e2function string bToHex(n, chars)
return bit.tohex(n, chars)
end

e2function number operator_band( a, b )
e2function number operator_band(a, b)
return bit.band(a, b)
end
e2function number operator_bor( a, b )

e2function number operator_bor(a, b)
return bit.bor(a, b)
end
e2function number operator_bxor( a, b )

e2function number operator_bxor(a, b)
return bit.bxor(a, b)
end
e2function number operator_bshr( a, b )

e2function number operator_bshr(a, b)
return bit.rshift(a, b)
end
e2function number operator_bshl( a, b )

e2function number operator_bshl(a, b)
return bit.lshift(a, b)
end
Loading