View source for Module:Color/utils/bitwise
From Space Station 14 Wiki
You do not have permission to edit this page, for the following reason:
You can view and copy the source of this page.
-- Implementations of bitwise operators so that lua-color can be used
-- with Lua 5.1 and LuaJIT 2.1.0-beta3 (e.g. inside Neovim).
-- Code taken directly from:
-- https://stackoverflow.com/questions/5977654/how-do-i-use-the-bitwise-operator-xor-in-lua
local function bit_xor(a, b)
local p, c = 1, 0
while a > 0 and b > 0 do
local ra, rb = a % 2, b % 2
if ra ~= rb then
c = c + p
end
a, b, p = (a - ra) / 2, (b - rb) / 2, p * 2
end
if a < b then
a = b
end
while a > 0 do
local ra = a % 2
if ra > 0 then
c = c + p
000
1:0
Template used on this page:
Return to Module:Color/utils/bitwise.