bit.clear

Clears one or more bits

Prototype

n = bit.clear (a, b, ...)

Description

This takes one or more arguments. All are converted to signed 'long long' (64-bit integers). The result is the first argument 'and'ed with the ones-complement of the other arguments.

In other words, you can clear any bits in the first argument which are set in subsequent arguments.

eg.

a = bit.clear (0x111, 0x01)  --> 0x110
a = bit.clear (0x111, 0x01, 0x10) --> 0x100
Note that setting a bit can be simply done with bit.bor.

Testing a bit can be done with bit.test.

Lua functions

Topics