avatar

logic

gates
symbolnameformula
¬negationnot(a) = 1 - a
conjunctionand(a, b) = a * b
alternative denialnand(a, b) = not(and(a, b))
nand(a, b) = 1 - a * b
disjunctionor(a, b) = a + b - a * b
joint denialnor(a, b) = not(or(a, b))
nor(a, b) = 1 - (a + b - a * b)
exclusive orxor(a, b) = a + b - 2 * a * b
 biconditionalxnor(a, b) = not(xor(a, b))
xnor(a, b) = 1 - (a + b - 2 * a * b)
1-input
a¬a
01
10
2-input
aba ∧ ba ⊼ ba ∨ ba ⊽ ba ⊻ ba XNOR b
00010101
01011010
10011010
11101001

bitwise

<< # shift left
>> # shift right
((x & 1) == 0) # check if x is even
(x & (1 << n)) # check if n-th bit is set
x | (1 << n) # set n-th bit
x & ~(1 << n) # unset n-th bit
x ^ (1 << n) # toggle n-th bit
x & (x - 1) # turn off rightmost 1-bit
x & (-x) # isolate rightmost 1-bit
x | (x - 1) # right propagate rightmost 1-bit
~x & (x + 1) # isolate rightmost 0-bit
x | (x + 1) # turn on rightmost 0-bit

bits