util.bit53: Add bnot() method

This commit is contained in:
Matthew Wild 2024-03-01 17:22:29 +00:00
parent 36a9583069
commit 876162b9cf
2 changed files with 7 additions and 0 deletions

View file

@ -24,4 +24,8 @@ describe("util.bitcompat", function ()
it("lshift works", function ()
assert.equal(0xFF00, bit.lshift(0xFF, 8));
end);
it("bnot works", function ()
assert.equal(0x0000FF00, bit.band(0xFFFFFFFF, bit.bnot(0xFFFF00FF)));
end);
end);

View file

@ -27,6 +27,9 @@ return {
end
return ret;
end;
bnot = function (x)
return ~x;
end;
rshift = function (a, n) return a >> n end;
lshift = function (a, n) return a << n end;
};