Summary
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).
See Also ...
Lua functions
bit.ashr - Shifts a number right, preserving sign
bit.band - Bitwise 'and'
bit.bor - Bitwise 'or'
bit.clear - Clears one or more bits
bit.mod - Bitwise 'modulus' (remainder after integer divide)
bit.shl - Shifts a number left
bit.shr - Shifts a number right
bit.test - Bitwise 'test'
bit.tonumber - Convert a string into a number
bit.tostring - Convert a number into a string
bit.xor - Bitwise 'exclusive or'
Topics
Lua base functions
Lua bc (big number) functions
Lua bit manipulation functions
Lua coroutine functions
Lua debug functions
Lua io functions
Lua LPEG library
Lua math functions
Lua os functions
Lua package functions
Lua PCRE regular expression functions
Lua script extensions
Lua string functions
Lua syntax
Lua table functions
Lua utilities
Scripting
Scripting callbacks - plugins
(Help topic: lua=bit.neg)