Skip to content
IGCSE·Tuition
Computer Science · Lessons

Convert between binary and denary

You can follow a binary conversion on the board, then freeze when a blank row of eight boxes is in front of you.

On this page
  1. How do place values work in binary?
  2. How do you convert denary to binary?
  3. Worked example
  4. How can the same method be written as an algorithm?
  5. The mistake to watch for
  6. Check yourself
  7. Where this leads next

To convert between binary and denary, use place values: in an 8-bit number the columns from left to right are worth 128, 64, 32, 16, 8, 4, 2 and 1. Binary to denary means adding the columns that hold a 1. Denary to binary means deciding, column by column, whether that place value fits.

This skill opens Representing numbers and text and returns in hexadecimal, binary addition and bit depth.

How do place values work in binary?

In denary, the number 345 means 3 hundreds, 4 tens and 5 ones. Each column is 10 times the one on its right. In binary each column is 2 times the one on its right, so the columns are 1, 2, 4, 8, 16, 32, 64, 128 reading from the right.

Column value1286432168421
Bit10110101

Add the values above each 1: 128 + 32 + 16 + 4 + 1 = 181. So 10110101 in binary is 181 in denary.

How do you convert denary to binary?

Work from the biggest column to the smallest. At each column ask: does this value fit into what is left?

  1. Write the eight column values above eight empty boxes.
  2. If the place value is less than or equal to the number left, write 1 and subtract it.
  3. If not, write 0 and leave the number unchanged.
  4. Continue until the last column. The number left should now be 0, which is your check.

Worked example

Convert 183 to 8-bit binary.

ColumnNumber left beforeFits?BitNumber left after
128183yes155
6455no055
3255yes123
1623yes17
87no07
47yes13
23yes11
11yes10

The answer is 10110111. Check by adding back: 128 + 32 + 16 + 4 + 2 + 1 = 183. It matches, and the number left ended at 0.

How can the same method be written as an algorithm?

The table above is exactly what this pseudocode does.

DECLARE Number : INTEGER
DECLARE Place : INTEGER
DECLARE Bits : STRING
Number ← 183
Place ← 128
Bits ← ""
WHILE Place >= 1
   IF Number >= Place
      THEN
         Bits ← Bits & "1"
         Number ← Number - Place
      ELSE
         Bits ← Bits & "0"
   ENDIF
   Place ← Place DIV 2
ENDWHILE
OUTPUT Bits

Trace it:

PlaceNumber >= Place?BitsNumber
128yes“1”55
64no“10”55
32yes“101”23
16yes“1011”7
8no“10110”7
4yes“101101”3
2yes“1011011”1
1yes“10110111”0

After Place = 1, Place becomes 0 and the loop stops. The output is 10110111. You can confirm in the Python reasoning sandbox with print(format(183, "08b")) and print(int("10110111", 2)).

The mistake to watch for

A common slip is reading the place values from the wrong end, so the left-most bit is treated as worth 1.

Question: Convert 110100 to denary.

Mistaken working: 1×1 + 1×2 + 0×4 + 1×8 + 0×16 + 0×32 = 11

The columns for a 6-bit number are 32, 16, 8, 4, 2, 1 from the left. The correct working is 32 + 16 + 4 = 52. To avoid the slip, write the column values above the bits before you add anything, always starting from 1 on the right and doubling as you move left.

Check yourself

1. Convert 00110110 to denary.

Show answer

Columns with a 1: 32, 16, 4, 2. Sum: 32 + 16 + 4 + 2 = 54.

2. Convert 200 to 8-bit binary.

Show answer

128 fits (72 left). 64 fits (8 left). 32 no, 16 no. 8 fits (0 left). 4, 2, 1 no. Bits: 1 1 0 0 1 0 0 0, so 11001000. Check: 128 + 64 + 8 = 200.

3. Why can an 8-bit register not store the denary number 256?

Show answer

The largest 8-bit value is 11111111 = 255. The number 256 needs a ninth column worth 256, so it needs 9 bits.

Where this leads next

Once conversions are quick, learn to use hexadecimal as a compact way to write binary, then try the mixed practice set. The Python reasoning sandbox and the pseudocode trace trainer let you test your own examples.

Some students can convert slowly and correctly but run out of time in a paper. That is a pattern our teachers can work on in online one-to-one Computer Science tuition.

Questions people ask

What is the difference between binary and denary?

Denary is the ordinary base 10 system with digits 0 to 9, where each place is worth ten times the one to its right. Binary is base 2 with digits 0 and 1, where each place is worth two times the one to its right. Computers use binary because a circuit is either on or off.

What is the largest number that 8 bits can store?

The largest is 11111111, which is 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. Counting 0 as well, 8 bits can represent 256 different values, from 0 to 255. A number such as 256 needs 9 bits.

Do I need to write leading zeros?

When a question asks for an 8-bit binary number, yes. 45 is 101101, but as an 8-bit number it is 00101101. The extra zeros do not change the value, but they show you are using the full 8 bits as the question asked.

Is there a faster method than subtracting place values?

You can divide repeatedly by 2 and read the remainders from the bottom up. Both methods give the same answer. Pick one, practise it until it is automatic, and use the other to check your result.

Sources

  1. Cambridge IGCSE Computer Science 0478 syllabus page

Updated:

Your next step

If you still lose track of place values when the number gets bigger, a one-to-one teacher can watch you convert a few numbers aloud and spot the habit that causes the slip.

Paid one-hour trial at your assigned teacher’s confirmed rate, starting from RM80. Other fees, schedules and ongoing arrangements are confirmed directly with your teacher after the trial class.

Tuition is arranged with a parent or guardian. Send them this page on WhatsApp and they can enquire for you.

Parent or guardian? Enquire here

9,000+ students helped through our service