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

WeightRemaining beforeBit decisionRemaining after
128130: too large13
64130: too large13
32130: too large13
16130: too large13
8131: subtract5
451: subtract1
210: too large1
111: subtract0

Step 2. Read bits in the same order

00001101.

Step 3. Reconstruct the decimal value

8 + 4 + 1 = 13.

Final answer: 00001101