Nand
is known as a 'universal' logic gate, because it allows you define all other boolean logic gates:
not(x) = nand(x,x)
and(x, y) = not(nand(x, y))
or(x, y) = nand(not(x), not(y))
nor(x, y) = not(or(x, y))
xor(x, y) = nand(nand(a, nand(a, b)), nand(b, nand(a, b)))
This is known as nand-logic, and is commonly used in modern computers because a transistor can be made to behave just like a nand-gate.
I am wondering if it is possible to do something similar with the bitwise operations. Can an e.g. bitwise nand (bnand) be used to define bnot
, bor
, band
, bnor
, bxor
? Is there an universal bitwise operation?