3.1.3 · D1Boolean Algebra & Logic Gates

Foundations — Two's complement signed numbers

1,981 words9 min readBack to topic

Before you can use that trick, you have to be fluent in the little symbols the parent note throws around: bits, place-values, the bar , the "mod" symbol, , the subscripts on . This page builds every one of them from nothing, in the order they depend on each other.


1. A bit — the single switch

Why the topic needs it: two's complement is a rule for reading a row of switches. If you don't picture the switch, the later symbols (, ) have nothing to stand on.


2. Subscripts and — naming each switch by its position

Figure — Two's complement signed numbers
  • = how many switches in the row (e.g. for a byte).
  • = the leftmost switch — the parent note calls it the most significant bit (MSB) and gives it the negative weight.
  • = the rightmost switch — the least significant bit.

3. Place-value and — why each switch is worth double the last

This is the foundation the whole topic sits on, so we build it slowly. See Binary number system for the unsigned home of this idea.

Figure — Two's complement signed numbers

Why the topic needs it: the parent's master formula is just this weighted sum, with one weight made negative.


4. The symbol — "add up a pattern"

Why the topic needs it: the definition uses to mean "the ordinary positive part (all switches except the top one)", then tacks on the top switch with a minus in front. Recognise the two pieces and the formula stops being scary.


5. The MSB with a negative weight — the heart of the trick

Figure — Two's complement signed numbers
  • Top off, rest anything: values to (the positives).
  • Top on: values up to (the negatives).
  • Together: — one more negative than positive.

Why the topic needs it: this is the topic. Everything else (negation rule, discarding carries) is a consequence.


6. The bar — flip every switch (NOT)

Why the topic needs it: the parent derives straight from this identity. No bar, no negation rule.


7. — the wrap-around clock

Figure — Two's complement signed numbers

Why the topic needs it:

  • It explains why (so really is the negative).
  • It explains why you discard the carry-out: the carry is worth , so throwing it away changes nothing.

8. and the carry symbols — for overflow

Why the topic needs it: this is the only extra symbol needed for the overflow rule .


How these foundations feed the topic

Bit: one switch 0 or 1

Position and subscript b_i

Place value 2 to the i

Summation adds weighted bits

Top bit negative weight

Two's complement value V

Bitwise NOT bar x

Identity x plus not x = 2^n minus 1

Modulo 2^n wrap around

Negation rule not x plus 1

Discard carry out

XOR and carries C

Overflow detection


Equipment checklist

Test yourself — you're ready for the parent note when you can answer each without peeking.

What does a single bit represent, physically?
One switch that is either off (0) or on (1) — the only alphabet a computer has.
In , which switch is and which is ?
is the rightmost (least significant); is the leftmost (most significant / MSB).
What is the weight of the switch at position in ordinary binary?
— each step left doubles the value.
What does mean in plain words?
Add up the weighted value of every switch except the top one.
What is different about the MSB's weight in two's complement?
It is (negative) instead of .
What does the bar in do?
Flips every bit: 01 (bitwise NOT).
What does always equal, and why?
(all ones), because every column has one 0 and one 1.
What does mean on an -bit machine?
and differ by a whole number of 's, so they look identical (the difference falls off the top).
Why can you discard the carry-out in signed addition?
It is worth , and , so dropping it changes nothing.
What does signal?
Carry into the MSB differs from carry out of it → signed overflow.

Connections