## 2. Converting a denary number into a binary number

Base 10 number system (denary)

In our everyday lives we use a 'Denary' number system which has the number digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9.

This is called a 'base-10' number system.

Here are some examples of denary numbers:

• 5
• 24
• 316
• 8715

Base 2 number system (binary)

You already know that computers can't work with our denary system, they need to use binary numbers to process data.

Binary is a 'base-2' type of number which has only two digits, a 1 or a 0

Here are some examples of binary numbers:

• 1
• 101
• 1101
• 11011001

The position of numbers

When working with any number system, be it denary, binary or hexadecimal, the position of the number is important in order for you to be able to calculate its value.

For example, with the denary system, think about the number 123.

The number on the far right, 3, is worth 3 units. The number to the left of 3, isn't worth 2, instead it is worth 20. Because its position is one to the left of 3, it has been multiplied by 10, so it is 3 + (10 * 2)

Now think about the number 1 in 123. Again, this isn't worth the value of 1, and it hasn't been multiplied by 10 as the 2 was. Because it is one position further to the left than 2, it is multiplied by 100, meaning it is worth 100.

So 123 is arrived at by using the following calculation: 3 + (10 * 2) + (100 * 1)

The rule with base-10 numbers is to multiply each digit on the left by a progressive factor of 10 in order to calculate its value.

Calculating binary numbers

Likewise, when working with binary numbers, the position is important in order for you to be able to calculate the correct value.

The value 1 in binary represents the value one, the value 0 represents zero.

For base-two binary numbers, you need to multiply each digit on the left by a progressive factor of 2. As with denary numbers, the calculations always work from right to left.

Example 1: Denary = 1

 128 64 32 16 8 4 2 1 0 0 0 0 0 0 0 1

(1 * 1) = 1

Example 2: Denary = 3

 128 64 32 16 8 4 2 1 0 0 0 0 0 0 1 1

(1 * 1) + (2 * 1) = 3

Example 3: Denary = 6

 128 64 32 16 8 4 2 1 0 0 0 0 0 1 1 0

(1 * 0) + (2 * 1) + ( 4 * 1) = 6

Example 4: Denary = 12

 128 64 32 16 8 4 2 1 0 0 0 0 1 1 0 0

(1 * 0) + (2 * 0) + (4 * 1) + (8 * 1) = 12

Example 5: Denary = 37

 128 64 32 16 8 4 2 1 0 0 1 0 0 1 0 1

(1 * 1) + (2 * 0) + (4 * 1) + (8 * 0) + (16 * 0) + (32 * 1) = 37

Example 6: Denary = 115

 128 64 32 16 8 4 2 1 0 1 1 1 0 0 1 1

(1 * 1) + (2 * 1) + (4 * 0) + (8 * 0) + (16 * 1) + (32 * 1) + (64 * 1) = 115

Example 7: Denary = 255

 128 64 32 16 8 4 2 1 1 1 1 1 1 1 1 1

Answer: Binary = 11111111 (the maximum 8 digit binary number)

(1 * 1) + (2 * 1) + (4 * 1) + (8 * 1) + (16 * 1) + (32 * 1) + (64 * 1) = 255

if the digit is a 0 then just don't add that value to the total. The number below has a 0 in the 32 position and the binary number in decimal is:

1 1 0 1 1 1 1 1
1x128 + 1x64 + 0x32 + 1x16 + 1x8 + 1x4 + 1x2 + 1x1 = 223 decimal

Let's try a smaller binary number:

What is 10101 in decimal?

1 0 1 0 1
1x16 + 0x8 + 1x4 + 0x2 + 1x1 = 21 decimal

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: Binary Numbers