Repeated division by 2 gives the binary digits (remainders). Pad the result with leading 0’s to obtain an 8‑bit pattern.
45 ÷ 2 = 22 r 1 22 ÷ 2 = 11 r 0 11 ÷ 2 = 5 r 1 5 ÷ 2 = 2 r 1 2 ÷ 2 = 1 r 0 1 ÷ 2 = 0 r 1 → binary 101101 → 8‑bit 00101101
Convert the decimal number to binary, group the bits into nibbles (4‑bit groups) and replace each nibble by its hex digit.
45₁₀ → 0010 1101₂ → 2D₁₆
Conversely, to go from hexadecimal to decimal, expand each hex digit to its 4‑bit binary form and then evaluate the binary value.
1010 1100 → nibble 1010=A, 1100=C → AC₁₆.7F → binary 0111 1111.When two 8‑bit numbers are added, any carry out of the most‑significant bit (MSB) is discarded. Overflow occurs when the carry into the sign bit differs from the carry out of the sign bit.
00101101 (+45) + 00010110 (+22) ------------ 00111111 (+67) ← no overflow (carry‑in = carry‑out = 0) 01111111 (+127) + 00000001 (+1) ------------ 10000000 (‑128) ← overflow: carry‑in = 0, carry‑out = 1
In an 8‑bit two’s‑complement word the most‑significant bit (MSB) is the sign bit. The representable range is
–2⁷ … 2⁷‑1 = –128 to 127
The final 8‑bit pattern is the two’s‑complement representation of –N. The sign bit is 1.
00000000 (the final carry is discarded).45 – 23 00101101 (+45) + 11101001 (‑23) ← two’s‑complement of 23 ------------ 00010110 (+22) ← correct result, no overflow
After an 8‑bit addition, examine the two carries around the sign bit:
In programmes this test is used to flag arithmetic errors before using the result.
Examples (8‑bit):
00110101₂ (53) << 1 → 01101010₂ (106) 10011010₂ (‑102) << 1 → 00110100₂ (52) ← sign bit flipped → overflow 01101010₂ (106) >> 1 → 00110101₂ (53)
Binary: 00101101 Hex: 2D
45 → 00101101 invert → 11010010 +1 → 11010011 Result: 11010011₂ = D3₁₆
45 → 00101101 23 → 00010111 → invert → 11101000 → +1 → 11101001 (‑23) Add: 00101101 +11101001 --------- 00010110 (= 22₁₀)
01111111 (+127) +00000001 (+1) ------------ 10000000 (‑128) ← overflow (carry‑in = 0, carry‑out = 1)
Left shift: 00110101 (53) << 1 → 01101010 (106) Right shift: 01101010 (106) >> 1 → 00110101 (53)
| Decimal | 8‑bit Two’s‑Complement | Hexadecimal |
|---|---|---|
| -128 | 10000000 | 80 |
| -100 | 10011100 | 9C |
| -64 | 11000000 | C0 |
| -45 | 11010011 | D3 |
| -23 | 11101001 | E9 |
| -1 | 11111111 | FF |
| 0 | 00000000 | 00 |
| 1 | 00000001 | 01 |
| 15 | 00001111 | 0F |
| 23 | 00010111 | 17 |
| 45 | 00101101 | 2D |
| 64 | 01000000 | 40 |
| 85 | 01010101 | 55 |
| 100 | 01100100 | 64 |
| 127 | 01111111 | 7F |
11101010, state the decimal value it represents in two’s complement.00110101 and give the decimal result.10000000 represents –0; in two’s complement there is only one zero: 00000000.Two’s complement provides a single binary format for signed integers. In an 8‑bit system the sign bit is the MSB and the range is –128 to 127. Positive values are written directly; negative values are obtained by inverting the magnitude and adding 1. The same adder circuitry can perform addition, subtraction (by adding the two’s‑complement of the subtrahend) and logical shifts. Overflow is detected by comparing the carry into and out of the sign bit, a technique useful for simple error‑checking in programmes. Mastery of these conversions underpins all low‑level programming and debugging tasks required by the Cambridge IGCSE 0478 syllabus.
Create an account or Login to take a Quiz
Log in to suggest improvements to this note.
Your generous donation helps us continue providing free Cambridge IGCSE & A-Level resources, past papers, syllabus notes, revision questions, and high-quality online tutoring to students across Kenya.