bit.neg

Bitwise 'negate' (ones complement)

Prototype

n = bit.neg (a)

Description

This takes one argument. It is converted to a signed 'long long' (64-bit integer). The result is the ones-complement of the number (zero bits become one, one bits become zero).
eg.

print (bit.neg (1)) --> -2
print (bit.band (14, bit.neg (8)))  --> 6  (clear 8-bit)
Also see bit.clear to achieve the same affect (clearing a bit).

Lua functions

Topics