Before you can trust a single line of C, you need a small toolbox of ideas that the parent note quietly assumes. This page builds each one from nothing — plain words, then a picture, then why the topic needs it. Every symbol is defined before it is used: we start with the two plainest words, then the atoms (bits), then earn each operator symbol one at a time.
Before any symbol, pin down the two plainest words the core idea leans on.
Everything below is the machinery that decides which new value comes out. Keep those two words in hand; the whole page is about the values that flow into operators and the values that flow back out.
Everything a computer does is built from a bit: a single tiny switch that is either off (0) or on (1). That's the whole vocabulary — two states.
A number like 12 is not stored as the shape "12"; it is stored as a row of switches. Look at the figure: the number is written in base 2, meaning each switch is worth double the one to its right.
Why base 2 and not base 10? Because a wire is easiest to build as "voltage or no voltage" — two states. The whole machine is cheapest when its alphabet has exactly two letters.
The place values 1, 2, 4, 8, 16, ... are the powers of two. We write 2n to mean "multiply 2 by itself n times", where n is a whole number 0,1,2,3,… (we never need negative n here — a negative exponent like 2−1 would mean the fraction 21, and switch-columns only ever go up in whole steps). By convention 20=1 (multiplying zero twos leaves you with 1, the starting point).
(The right shift also lives here, but reasoning about it needs the "floor" idea and the sign switch — we build both in the next two sections, then state the shift rule cleanly once we have the tools.)
The parent says integer /truncates toward zero. Three words, three meanings — let's earn them on a number line.
For positive numbers truncate and floor agree (3.5 → 3 either way). They only differ for negatives — which is exactly why the parent's -7/2 = -3 example needs this distinction.
The parent writes -7 / 2 and -7 % 2. But if a byte is just switches worth 1,2,4,8,…, how is anything negative? The trick is called two's complement: the leftmost switch is given a negative place value.
How do you actually build −7 from +7? The recipe is invert every bit, then add 1 (here "invert" means flip every switch, the ~ operation earned in section 9):
Start with +7=0000 0111.
Invert every switch: 1111 1000.
Add 1: 1111 1001.
Check that this really is −7 using the negative top-bit: −128+64+32+16+8+1=−7. ✓
Why invert-and-add-1 works, in one sentence: inverting turns x into "(all-ones) −x", and all-ones is −1 in this scheme, so inverting gives −1−x; adding 1 lands you on −x. The full story lives in Two's Complement Representation; here you only need the picture: the top switch is a "sign switch", and negatives are made by invert-and-add-1.
Section 2 showed a number is a row of switches. These four operators work column by column on those switches. (~ is the "invert" tool we borrowed early in section 5 — here is its full definition.)
The diagram below is a dependency chart: read an arrow X --> Y as "you need X before Y makes sense." Follow any path and you'll see the order this page built things in — bits at the top feed everything, and every strand eventually flows down into the Operators topic itself.
Self-test: cover the right side and answer out loud.
A value and an operator are
a piece of data the program holds; and a symbol that takes operands (values) and produces a new value.
What do +, - (binary), and * each do to two values?
+ sums them; binary - takes the right from the left; * multiplies (repeated addition).
A bit and a byte are
a single on/off switch (0 or 1); and a row of bits C treats as one chunk — 8 on almost every machine, guaranteed at least 8 (CHAR_BIT).
Why is a number stored in base 2?
because a wire is cheapest as two states (voltage or none), so each column is worth double the one right of it.
2n means, and its domain of n
multiply 2 by itself n times, with n a whole number 0,1,2,…; sliding switches n columns left multiplies by 2n.
The floor⌊x⌋ means
the greatest whole number not larger than x (round down toward −∞); -3.5 → -4.
How do you form −7 from +7 in two's complement?
invert every bit then add 1: 0000 0111 → 1111 1000 → 1111 1001; the top bit carries weight −128.
Difference between truncate toward zero and floor
they agree for positives; for negatives truncate keeps the value closer to 0 (-3.5→-3) while floor goes down (-3.5→-4).
What do << and >> compute for a non-negative x?
x << n = x * 2**n; x >> n = floor(x / 2**n).
Is x >> n == floor(x / 2**n) always true?
only for x >= 0; for negative signed x right-shift is implementation-defined, so use unsigned for bit work.
Why does 5/2 differ from 5/2.0?
/ reads operand types; two ints give integer division, a double gives real division.
What are / and % for integers, and what sign does % keep?
/ = whole times divisor fits (truncated toward zero); % = the leftover remainder, keeping the sign of the dividenda (never the divisor b).
What is -7 % -2 and why?
-1; -7 / -2 truncates 3.5 → 3, so -7 - 3*(-2) = -7 + 6 = -1, keeping the sign of the dividend.
What do & | ^ ~ each do to a column of bits?
AND keeps common ONs; OR keeps any ON; XOR keeps disagreements; NOT (unary) flips every bit.
How do the six relational/equality operators behave, and what do they return?
< > <= >= == != ask a yes/no question about two values and return an int1 (true) or 0 (false).
What do &&, ||, and ! do, and how do they read their operands?
they read 0 as false and any nonzero as true; && true if both, || true if either, ! flips one truth value; result is 1 or 0.
Difference between && and &
&& reduces two values to a single true/false; & works column by column and can return any number. 1 && 2 is 1, 1 & 2 is 0.
In C, true is
any nonzero value; false is exactly 0; relational/logical ops return a clean 1 or 0.
Arity of ?:, !, and + (as in a+b)
ternary (3), unary (1), binary (2).
Precedence vs associativity, and which operators are right-associative
precedence = who fires first; associativity = tie-breaker for equals; most operators group left→right, but assignment, ?:, and unary prefixes group right→left.