I see that Defold has its own lib for bitwise operations (https://www.defold.com/ref/bit)
I’m wondering what’s the equivalent for >>> (Zero-fill right shift) from JavaScript.
Apparently LuaBit has this method, which has the following signature:
-- LuaBit's zero-fill right shift
bit.blogic_rshift(n, bits) -- logic right shift(zero fill >>>)
-- logic rightshift assures zero filling shift
local function bit_logic_rshift(n, bits)
if(n < 0) then
n = bit.bnot(math.abs(n)) + 1
end
for i=1, bits do
n = n/2
end
return math.floor(n)
end
“Returns the bitwise logical right-shift of its first argument by the number of bits given by the second argument. Logical shifts treat the first argument as an unsigned number and shift in 0-bits.”
”This operator shifts the first operand the specified number of bits to the right. Excess bits shifted off to the right are discarded. Zero bits are shifted in from the left. The sign bit becomes 0, so the result is always non-negative.”