Computer Networks · TEE · read
Decimal to binary · example 1
Essential vocabulary and maths
TEE prerequisites
Practice question. Write decimal 13 as an 8-bit binary octet. [3 practice marks]
Answer
Given
Decimal value = 13.
To find
Eight bits, including leading zeroes.
Formula and why
Use the weights 128,64,32,16,8,4,2,1.
At each weight, write 1 and subtract if the remaining value is at least that weight; otherwise write 0.
Step-by-step solution
Step 1. Choose each bit
| Weight | Remaining before | Bit decision | Remaining after |
|---|---|---|---|
| 128 | 13 | 0: too large | 13 |
| 64 | 13 | 0: too large | 13 |
| 32 | 13 | 0: too large | 13 |
| 16 | 13 | 0: too large | 13 |
| 8 | 13 | 1: subtract | 5 |
| 4 | 5 | 1: subtract | 1 |
| 2 | 1 | 0: too large | 1 |
| 1 | 1 | 1: subtract | 0 |
Step 2. Read bits in the same order
00001101.
Step 3. Reconstruct the decimal value
8 + 4 + 1 = 13.
Final answer: 00001101