Binary Addition and Shifts

Binary Addition Rules

ABSumCarry
0000
0110
1010
1101
1 + 1 + 1 (carry)11

Key rule: 1 + 1 = 0, carry 1


Performing Binary Addition

Always work right to left, column by column. Show carries explicitly.

Example: Add 01001011 (75) + 00110100 (52)

    01001011  (75)
  + 00110100  (52)
  ──────────
  ← carry bits: 0 0 1 0 0 0 0 0
    01111111  (127) ✓

Overflow

Overflow occurs when the result of an addition exceeds what can be stored in the available number of bits.

  • For an 8-bit unsigned number, the maximum value is 255
  • If the sum requires a 9th bit (carry out of the leftmost column), the result overflows
  • The carry bit is lost and the stored result is invalid

Overflow Example

11111111 (255) + 00000001 (1) = 100000000, the 9th bit is lost, leaving 00000000 (0), which is clearly wrong.


Binary Shifts

A binary shift moves all bits left or right by a number of positions.

Logical Left Shift

  • All bits move left by n places
  • Empty spaces on the right are filled with 0
  • Bits that fall off the left edge are lost
  • Effect on unsigned numbers: multiplies by 2ⁿ

Example: 00000011 (3) left shift by 1 → 00000110 (6) ✓

Logical Right Shift

  • All bits move right by n places
  • Empty spaces on the left are filled with 0
  • Bits that fall off the right edge are lost
  • Effect on unsigned numbers: divides by 2ⁿ (integer division)

Example: 00001100 (12) right shift by 2 → 00000011 (3) ✓


Logical vs Arithmetic Shifts

Logical ShiftArithmetic Shift
Fills empty bits with0 (always)Copies the MSB (sign bit)
Safe for unsignedYesN/A
Safe for signed (two’s complement)Left: No; Right: NoRight: Yes
Left shift on signedCan corrupt sign bitAlso unsafe

Why Logical Right Shift Breaks Negative Numbers

In Two’s Complement, the MSB is the sign bit. A logical right shift inserts a 0 into the MSB position, making a negative number appear positive, incorrect.

Arithmetic Right Shift

  • Inserts a copy of the existing MSB into the new MSB position
  • Preserves the sign of the number
  • Correctly divides signed (two’s complement) numbers by 2

Exam Questions

Q: What is the result of 1 + 1 in binary?

0 with a carry of 1.

Q: What is overflow?

Overflow occurs when the result of a calculation requires more bits than are available. The extra bits are lost and the result stored is invalid.

Q: What is the effect of a left logical shift by one place on an unsigned binary number?

It multiplies the number by 2, because each bit moves to a column with twice the value.

Q: Why cannot a logical right shift be used on a negative two’s complement number?

A logical right shift replaces the MSB with 0, destroying the sign bit and incorrectly making the number appear positive.


Exam Tip

Shift questions often ask for the effect (×2 or ÷2). Always state whether bits are lost and what fills the empty spaces.