# HG changeset patch # User Matthew Wild # Date 1709313749 0 # Node ID 9912baa541c045c91af6c62373b4acf267e551a1 # Parent 93b4ce0115f0b53c0ca6e00c7b80176db53e20d2 util.bit53: Add bnot() method diff -r 93b4ce0115f0 -r 9912baa541c0 spec/util_bitcompat_spec.lua --- a/spec/util_bitcompat_spec.lua Wed Feb 28 22:31:06 2024 +0100 +++ b/spec/util_bitcompat_spec.lua Fri Mar 01 17:22:29 2024 +0000 @@ -24,4 +24,8 @@ 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); diff -r 93b4ce0115f0 -r 9912baa541c0 util/bit53.lua --- a/util/bit53.lua Wed Feb 28 22:31:06 2024 +0100 +++ b/util/bit53.lua Fri Mar 01 17:22:29 2024 +0000 @@ -27,6 +27,9 @@ 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; };