The Binary Number System

Learn Computer Science > Theory of Computer Science > The Binary Number System

The Binary Number System

People count in base-10. You might call this ‘decimal’ but in Computer Science you’ll see the term denary more commonly used. We probably use base-10 because we have 10 fingers but there is no reason why computers should use base-10, and they don’t!

For the CAIE 2023 syllabus you should understand the reasons why computers use binary.

Cambridge IGCSE (9-1) Computer Science 0984

If we wanted to make a computer that counted in the same way we do (base-10) then we’d need to build ‘circuits’ that could reliably be held at 1 of 10 different voltage levels (0 volts up to 9 volts perhaps) so that all of the possible values could be stored . Of course, it’s much easier to just have switches are either ‘off’ (0 volts) or ‘on’ (perhaps 5 volts). So .

So since the earliest days of digital computers base-2 (binary) was the only practical option.

When answering an examination question on the reasons why computers use binary you can discuss:

  • Processors consist of transistors (switches) which are either ‘open’ (off) or ‘closed’ (on)
  • So ultimately data has to be encoded in a form that can be processed by in this simple on/off, 0/1 form

Binary doesn’t have to be scary!

Before we talk about binary it is worth realising that the ideas we will use are exactly the same as you have already seen in your maths lessons (and everyday life).

Place values for denary numbers

With the ‘normal’ denary (base-10) number system each place value is worth 10 times as much as we move from right to left. That’s because the number base is 10. The number one hundred and twenty three is shown and the place values of the digits are probably well-known to you 🙂

In denary we have 10 digits, 0,1,2,3,4,5,6,7,8,9 and that’s also because the number base is 10.

The difference when we are using base-2, binary, is that the number base is 2 and we only have two possible digits, 0 and 1.

Place values for binary numbers

So in binary each place value (going from right to left) is worth 2 times as much. We start with the ones (units) column on the left and then, doubling each time, we have columns for 2,4,8,16…

How do we show that a number is binary or denary?

When we write these two numbers we could just write 123 and 101 but that’s not clear because the number 123 is base-10 and the number 101 is base-2. To make it clear, to a reader, we add a little 10 or 2 after the number:

12310 means that it is 123 in denary

1012 means that it is 101 in binary

Later on we’ll talk about hexadecimal which is base-16. You can probably guess how we show that a number is in base-16.

Bits and Bytes

Computer memory is organised into groups of 8 bits. A single group of 8 bits is called a byte. You can find out more about computer memory here. In this section about binary this is important as we normally encounter binary numbers written in groups of 8 bits.

An 8-bit binary number

Question: Have a look at the binary number above (11010101) and the place values of each digit. What denary number do you think this is equivalent to?

For the CAIE syllabus you might see binary numbers up to 16 bits in size.

Cambridge IGCSE (9-1) Computer Science 0984

Converting between Binary and Denary

Computers only use binary and people mostly use denary. So one of the main things you need to be able to do is to convert between these two number bases.

Converting Binary to Denary

If you want to do this yourself then write down the place values from 128, on the left, down to 1 on the right as in the and then put each binary digit (the 0’s and 1’s) into a row below that, like in the image below.

The process can be summarised like this:

“Every time you see a 1 digit add the place value, for every 0 digit ignore the place value

  • We see that the place values for 128,64,16,4 and 1 have 1 digits so we add these place values up:
  • 128 + 64 + 16 + 4 + 1 = 213
  • We ignore the place values where there is a o digit which in this case means we ignore 32,8 and 2

So 110101012 is the same number as 21310

Converting Denary to Binary

Converting from denary to binary works like this:

Let’s take the number 235 as an example (I’ve chosen a number less than 255 on purpose).

Starting from the highest place value on the righthand side, in this case 128

  1. Can we fit 128 into tour number (235)? Yes we can, so put a 1 into the row below the 128
  2. Calculate the remainder, 235 – 128 = 107
  3. Move to the next place value, 64.
  4. Can we fit 64 into 107? Yes we can, so put a 1 into the row below 64
  5. Calculate the remainder, 107 – 64 = 43
  6. Move to the next place value, 32
  7. Can we fit 32 into 43? Yes we can, so put a 1 into the row below 32
  8. Calculate the remainder, 43 – 32 = 11
  9. Move to the next place value, 16
  10. Can we fit 16 into 11? No we cannot, so put a 0 into the row below 16
  11. Move to the next place value, 8
  12. Can we fit 8 into 11? Yes we can, so put a 1 into the row below 8
  13. Calculate the remainder, 8 – 11 = 3
  14. Move to the next place value, 4
  15. Can we fit 4 into 3? No we cannot, so put a 0 into the row below 4
  16. Move to the next place value, 2
  17. Can we fit 2 into 3? Yes we can, so put a 1 into the row below 2
  18. Calculate the remainder, 3 – 2 = 1
  19. Move to the next place value, 1
  20. Can we fit 1 into 1? Yes we can, so put a 1 into the row below 1

The final result is shown below:

Leave a Reply

Your email address will not be published. Required fields are marked *

Cookie Consent with Real Cookie Banner