Computer Binary Arithmetic

Computers calculate with only two digits: 0 and 1. Every sum, difference, and product inside a processor follows simple binary rules. Picture a row of light switches. Each switch is either off (0) or on (1), and the pattern of switches stores a number. Learning these rules shows how a machine with no understanding of numbers still does perfect math.

Place Values in Binary

Decimal columns grow by tens: ones, tens, hundreds. Binary columns grow by twos: 1, 2, 4, 8, 16.

Binary number: 1 0 1 1
Place values:  8 4 2 1
Calculation:   8 + 0 + 2 + 1 = 11

Binary Addition

Only five basic rules exist.

0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 10   (write 0, carry 1)
1 + 1 + 1 = 11   (write 1, carry 1)

Carrying works exactly like decimal addition. Ten in decimal forces a carry. Two in binary forces a carry.

Worked Example: 1011 + 0110

carry    1 1 1 0 0
num 1      1 0 1 1      (11)
num 2    + 0 1 1 0      (6)
         ───────────
sum      1 0 0 0 1      (17)

Work from the right edge. Column one gives 1 + 0 = 1. Column two gives 1 + 1 = 10, which means write 0 and carry 1. Column three gives 0 + 1 + 1 = 10, which again means write 0 and carry 1. Column four gives 1 + 0 + 1 = 10, and the carry moves left once more. The last carry becomes the leftmost digit. The answer, 10001, equals 17.

Binary Subtraction

Processors rarely build a separate subtraction circuit. A smarter trick turns subtraction into addition using two's complement. The method represents a negative number by flipping every bit and adding 1.

Worked Example: 9 − 5 in 8 Bits

Step 1: Write 5            00000101
Step 2: Flip every bit     11111010
Step 3: Add 1              11111011   (this pattern means -5)
Step 4: Add 9 + (-5)       00001001
                         + 11111011
                         ──────────
                         1 00000100
Step 5: Drop the extra left carry → 00000100 = 4

The answer is 4, which matches 9 − 5. The same adder circuit handles addition and subtraction, which keeps the processor simple and fast.

Binary Multiplication

Multiplication uses shifting and adding. Multiplying by 1 copies the number. Multiplying by 0 gives zero. Each new row shifts one place to the left.

Example: 101 × 11   (5 × 3)

        1 0 1
      ×   1 1
      ─────────
        1 0 1     ← 101 × 1
      1 0 1 0     ← 101 × 1, shifted left
      ─────────
      1 1 1 1     = 15

Binary Division

Division repeats subtraction and shifting, much like long division on paper. Hardware performs it with a series of compare, subtract, and shift steps. Dividing by 2 has a shortcut: shift every bit one place to the right.

1100 (12)  shifted right once →  0110 (6)   = 12 ÷ 2

Overflow

Every register holds a fixed number of bits. When a result needs more bits than the register offers, overflow occurs. A 4-bit register stores values from 0 to 15.

  1 1 1 1   (15)
+ 0 0 0 1   (1)
─────────
1 0 0 0 0   needs 5 bits
Register keeps only 4 bits → 0 0 0 0

Think of a car odometer that reads 99999 and rolls back to 00000. Programmers choose data sizes carefully to avoid overflow errors.

Why Binary Arithmetic Matters

  • It explains how the ALU in a CPU adds, subtracts, and compares.
  • It reveals why numbers have size limits in programs.
  • It builds the foundation for logic gates and low-level programming.

Hexadecimal: A Shortcut for Long Binary

Long strings of 0s and 1s tire the eye. Programmers group four bits into one hexadecimal digit. Hexadecimal uses the symbols 0 to 9 and A to F, where A means 10 and F means 15. The byte 11010110 becomes D6, which is far easier to read and write.

1101   0110
  ↓      ↓
  D      6      → 11010110 = D6

Checking Your Answers

Convert both inputs to decimal, calculate in decimal, and compare the result with the binary answer. This habit catches slips in carrying and shifting. Practice with small numbers until the rules feel natural.

Key Takeaways

  • Binary addition follows five simple rules with carrying.
  • Two's complement converts subtraction into addition.
  • Multiplication uses shift and add, and division by 2 uses a right shift.
  • Overflow happens when a result exceeds the available bits.