mirror of
https://github.com/bjc/prosody.git
synced 2025-04-03 21:27:38 +03:00
util.bit53: Add bnot() method
This commit is contained in:
parent
36a9583069
commit
876162b9cf
2 changed files with 7 additions and 0 deletions
|
@ -24,4 +24,8 @@ describe("util.bitcompat", function ()
|
||||||
it("lshift works", function ()
|
it("lshift works", function ()
|
||||||
assert.equal(0xFF00, bit.lshift(0xFF, 8));
|
assert.equal(0xFF00, bit.lshift(0xFF, 8));
|
||||||
end);
|
end);
|
||||||
|
|
||||||
|
it("bnot works", function ()
|
||||||
|
assert.equal(0x0000FF00, bit.band(0xFFFFFFFF, bit.bnot(0xFFFF00FF)));
|
||||||
|
end);
|
||||||
end);
|
end);
|
||||||
|
|
|
@ -27,6 +27,9 @@ return {
|
||||||
end
|
end
|
||||||
return ret;
|
return ret;
|
||||||
end;
|
end;
|
||||||
|
bnot = function (x)
|
||||||
|
return ~x;
|
||||||
|
end;
|
||||||
rshift = function (a, n) return a >> n end;
|
rshift = function (a, n) return a >> n end;
|
||||||
lshift = function (a, n) return a << n end;
|
lshift = function (a, n) return a << n end;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue