Worked example 1
A computer stores a positive integer as an 8-bit binary number. Convert the denary number 173 into: (i) 8-bit binary, and (ii) hexadecimal.
Show solution outline
(i) To convert 173 to binary, we find the largest power of 2 that fits into it and work down. Place values: 128, 64, 32, 16, 8, 4, 2, 1
173 - 128 = 45. So, we have a 1 in the 128s place. 1....... 45 is less than 64. So, a 0 in the 64s place. 10...... 45 - 32 = 13. So, a 1 in the 32s place. 101..... 13 is less than 16. So, a 0 in the 16s place. 1010.... 13 - 8 = 5. So, a 1 in the 8s place. 10101... 5 - 4 = 1. So, a 1 in the 4s place. 101011.. 1 is less than 2. So, a 0 in the 2s place. 1010110. 1 - 1 = 0. So, a 1 in the 1s place. 10101101
Answer (i): 10101101
(ii) To convert to hexadecimal, we split the 8-bit binary number into two 4-bit nibbles. 1010 | 1101
Convert each nibble to denary/hex: 1010₂ = (8 + 2) = 10₁₀ = ₁₆ 1101₂ = (8 + 4 + 1) = 13₁₀ = ₁₆
Combine the two hex digits.
Answer (ii): AD₁₆