Add new comment

Maths in a minute: Binary numbers

Binary

 

Most people are aware of the fact that computers work using strings of 0s and 1s. But how do you write numbers using only those two symbols?

To see how, let's first remind ourselves of how the ordinary decimal way of writing numbers works. Let's take the number 4302 as an example. The digit 4 in this number doesn't stand for the number 4, rather it stands for 4000, or 4 x 1000. Similarly, 3 doesn't stand for 3 but for 300 = 3 x 100, 0 stands for 0 x 10, and 2 stands for 2 x 1. So 4302 means

4 x 1000 + 3 x 1000 + 0 x 10 + 2 x 1.

Similarly, 7396 stands for

7 x 1000 + 3 x 100 + 9 x 10 + 6 x 1.

What do the numbers 1000, 100, 10 and 1, which appear in these expressions, have in common? They are all powers of 10:

1000 = 103
100 = 102
10 = 101
1 = 100.
 

To write a number in decimal notation, you first write it as a sum of consecutive powers of 10 (with the largest power on the left) and then pull out the coefficients of these powers. We can do the same with powers of 2 rather than 10. For example, the binary number 110 stands for

1 x 22 + 1 x 21 + 0 x 20 = 4 + 2 +0 = 6 (written in decimal).

And the binary number 10001 stands for

1 x 24 + 0 x 23 + 0 x 22 + 0 x 21 + 1 x 20 = 16 + 0 + 0 + 0 + 1 = 17 (written in decimal).

You can convince yourself that a binary number only consists of the digits 0 or 1: when you write a number as a sum of consecutive powers of 2, no other coefficients are necessary.

This sorts out the natural numbers, but what about numbers that have a fractional part? To write a number between 0 and 1 in binary, you play the same game using powers of 1/2 instead of powers of 2. For example,

0.75 = 1/2 + 1/4 = 1 x 1/21+ 1 x 1/22.

In binary, 0.75 is written as 0.11. The binary number 0.1001 stands for the decimal number

1 x 1/21+ 0 x 1/22 + 0 x 1/23+ 1 x 1/24 = 1/2 + 1/16 =0.5625.

Easy!

You can find out more about the positional way of writing numbers here and about the use of 0s and 1s in logical operations here.

Unformatted text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.