Boolean Algebra
Boolean algebra is the original theory that deals with only true and false. This area of math gave us AND, OR, XOR, NOT, and more for boolean inputs.
It's the basis of the bitwise and binary-arithmetic fields. In the end, computers use boolean operators to do binary arithmetic.
This is a key mental model. Binary and boolean aren't the same. Binary is just used to represent boolean values.

Standard Boolean Operatorsโ
| Operator | Symbol | Description | Input causing output = True | Input causing output = False |
|---|---|---|---|---|
| NOT | ยฌ, ~ | Flips the value | Input = False | Input = True |
| AND | โง, ยท | True only if both are true | Both True | Any False |
| OR | โจ, + | True if at least one is true | Any True | Both False |
| XOR | โ, โป | True if inputs are different | Inputs differ | Inputs same |
| NAND | โ, โผ | Opposite of AND | Any False | Both True |
| NOR | โ, โฝ | Opposite of OR | Both False | Any True |
| XNOR | โ, โก | True if inputs are the same | Inputs same | Inputs differ |
Bitwise operators aren't part of boolean algebra. We often call everything bitwise, but that's wrong.
Bit shifts and rotates are the bitwise operators.
Arithmetic Negationโ
Arithmetic negation is the negative form of a positive number. The best mental model is the modular operation. It uses a circular counter. For positive numbers, you move clockwise from zero. For negative numbers, you move the other way from zero.
Since , negating gives the value that, when added to the original, brings the pointer on the ring back to zero. So is always (.
The makes the counter reach zero.
Remember this key model. At the CPU register level, numbers sit on a circular ring. It starts at 0 and goes up to , based on the variable size.

When you view the number range as a circle, x isn't geometrically opposite to -x.
- Boolean NOT. Flips true to false and vice versa.
- Arithmetic negation - Subtracts a number from zero.
- Bitwise NOT - Flips every individual bit from 0 to 1 and 1 to 0.