19TH DECEMBER 2014

Welcome to our binary numbers guide.

In this section we will explain what binary is and show you how to convert between binary and decimal (denary) numbers.

We will also show you how to perform various mathematical operations on binary numbers, including multiplication and division.

Binary is a number system used by digital devices such as computers, smartphones and tablets. It is also used in digital audio devices such as cd players and MP3 players.

*Electronically binary numbers are stored/processed using off or on electrical pulses, a digital system will interpret these off and on states as 0 and 1. In other words if the voltage is low then it would represent 0 (off state), and if the voltage is high then it would represent a 1 (on state)*.

advertisement

Binary is Base 2, unlike our counting system decimal which is Base 10 (denary).

In other words, Binary has only 2 different numerals (0 and 1) to denote a value, unlike Decimal which has 10 numerals (0,1,2,3,4,5,6,7,8 and 9).

Here is an example of a binary number: 10011100

As you can see it is simply a bunch of zeroes and ones, there are 8 numerals in all which make this an 8 bit binary number. Bit is short for Binary Digit, and each numeral is classed as a bit.

The bit on the far right, in this case a 0, is known as the Least significant bit (LSB).

The bit on the far left, in this case a 1, is known as the Most significant bit (MSB)

notations used in digital systems:

4 bits = Nibble

8 bits = Byte

16 bits = Word

32 bits = Double word

64 bits = Quad Word (or paragraph)

When writing binary numbers you will need to signify that the number is binary (base 2), as an example let's take the value 101. As it is written, it would be hard to work out whether it is a binary or decimal (denary) value. To get around this problem it is common to denote the base to which the number belongs by writing the base value with the number, for example:

101_{2} is a binary number and 101_{10} is a decimal (denary) value.

Once we know the base then it is easy to work out the value, for example:

101_{2} = 1*2^{2} + 0*2^{1} + 1*2^{0} = 5 (five)

101_{10} = 1*10^{2} + 0*10^{1} + 1*10^{0} = 101 (one hundred and one)

One other thing about binary numbers is that it is common to signify a negative binary value by placing a 1 (one) at the left hand side (most significant bit) of the value. This is called a sign bit, we will discuss this in more detail below.

In other words, Binary has only 2 different numerals (0 and 1) to denote a value, unlike Decimal which has 10 numerals (0,1,2,3,4,5,6,7,8 and 9).

Here is an example of a binary number: 10011100

As you can see it is simply a bunch of zeroes and ones, there are 8 numerals in all which make this an 8 bit binary number. Bit is short for Binary Digit, and each numeral is classed as a bit.

The bit on the far right, in this case a 0, is known as the Least significant bit (LSB).

The bit on the far left, in this case a 1, is known as the Most significant bit (MSB)

notations used in digital systems:

4 bits = Nibble

8 bits = Byte

16 bits = Word

32 bits = Double word

64 bits = Quad Word (or paragraph)

When writing binary numbers you will need to signify that the number is binary (base 2), as an example let's take the value 101. As it is written, it would be hard to work out whether it is a binary or decimal (denary) value. To get around this problem it is common to denote the base to which the number belongs by writing the base value with the number, for example:

101

Once we know the base then it is easy to work out the value, for example:

101

101

One other thing about binary numbers is that it is common to signify a negative binary value by placing a 1 (one) at the left hand side (most significant bit) of the value. This is called a sign bit, we will discuss this in more detail below.

To convert binary into decimal is very simple and can be done as shown below:

Say we want to convert the 8 bit value 10011101 into a decimal value, we can use a formula table like that below:

As you can see, we have placed the numbers 1, 2, 4, 8, 16, 32, 64, 128 (powers of two) in reverse numerical order, and then written the binary value below.

To convert, you simply take a value from the top row wherever there is a 1 below and then add the values together.

For instance, in our example we would have 128 + 16 + 8 + 4 + 1 = 157.

For a 16 bit value you would use the decimal values 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 (powers of two) for the conversion.

Because we know binary is base 2 then the above could be written as:

1*2^{7} + 0*2^{6} + 0*2^{5} + 1*2^{4} + 1*2^{3} + 1*2^{2} + 0*2^{1} + 1*2^{0} = 157.

Say we want to convert the 8 bit value 10011101 into a decimal value, we can use a formula table like that below:

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

1 | 0 | 0 | 1 | 1 | 1 | 0 | 1 |

As you can see, we have placed the numbers 1, 2, 4, 8, 16, 32, 64, 128 (powers of two) in reverse numerical order, and then written the binary value below.

To convert, you simply take a value from the top row wherever there is a 1 below and then add the values together.

For instance, in our example we would have 128 + 16 + 8 + 4 + 1 = 157.

For a 16 bit value you would use the decimal values 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 (powers of two) for the conversion.

Because we know binary is base 2 then the above could be written as:

1*2

To convert decimal to binary is also very simple, you simply divide the decimal value by 2 and then write down the remainder. Repeat this process until you cannot divide by 2 anymore, for example let's take the decimal value 157:

Next, write down the value of the remainders from bottom to top (in other words write down the bottom remainder first and work your way up the list) which gives:

10011101 = 157

157 ÷ 2 = 78 78 ÷ 2 = 39 39 ÷ 2 = 19 19 ÷ 2 = 9 9 ÷ 2 = 4 4 ÷ 2 = 2 2 ÷ 2 = 1 1 ÷ 2 = 0 |
with a remainder of 1 with a remainder of 0 with a remainder of 1 with a remainder of 1 with a remainder of 1 with a remainder of 0 with a remainder of 0 with a remainder of 1 |
<--- to convert write this remainder first. |

Next, write down the value of the remainders from bottom to top (in other words write down the bottom remainder first and work your way up the list) which gives:

10011101 = 157

Adding binary numbers is very similar to adding decimal numbers, first an example:

Let's look at the above example step by step:

1 + 1 = 0 (carry one)

1 + 1 (+ the carry) = 1 (carry one)

0 + 1 (+ the carry) = 0 (carry one)

1 + 0 (+ the carry) = 0 (carry one)

1 + 0 (+ the carry) = 0 (carry one)

0 + 1 (+ the carry) = 0 (carry one)

1 + 0 (+ the carry) = 0 (carry one)

The last carry is placed at the left hand side of the result giving: 10000010

Let's look at the above example step by step:

1 + 1 = 0 (carry one)

1 + 1 (+ the carry) = 1 (carry one)

0 + 1 (+ the carry) = 0 (carry one)

1 + 0 (+ the carry) = 0 (carry one)

1 + 0 (+ the carry) = 0 (carry one)

0 + 1 (+ the carry) = 0 (carry one)

1 + 0 (+ the carry) = 0 (carry one)

The last carry is placed at the left hand side of the result giving: 10000010

The most common way of subtracting binary numbers is done by first taking the second value (the number to be subtracted) and apply what is known as two's complement, this is done in two steps:

By applying these steps you are effectively turning the value into a negative number, and as when dealing with decimal numbers, if you add a negative number to a positive number then you are effectively subtracting to the same value.

In other words 25 + (-8) = 17, which is the same as writing 25 - 8 = 17.

An example, let's do the following subtraction 11101011 - 01100110 (235_{10} - 102_{10})

note: When subtracting binary values it is important to maintain the same amount of digits for each number, even if it means placing zeroes to the left of the value to make up the digits. For instance, in our example we have added a zero to the left of the value 1100110 to make the amount of numerals up to 8 (one byte) 01100110.

- complement each digit in turn (change 1 for 0 and 0 for 1).
- add 1 (one) to the result.

By applying these steps you are effectively turning the value into a negative number, and as when dealing with decimal numbers, if you add a negative number to a positive number then you are effectively subtracting to the same value.

In other words 25 + (-8) = 17, which is the same as writing 25 - 8 = 17.

An example, let's do the following subtraction 11101011 - 01100110 (235

note: When subtracting binary values it is important to maintain the same amount of digits for each number, even if it means placing zeroes to the left of the value to make up the digits. For instance, in our example we have added a zero to the left of the value 1100110 to make the amount of numerals up to 8 (one byte) 01100110.

advertisement

First we apply two's complement to 01100110

which gives us 10011010.

Now we need to add 11101011 + 10011010, however when you do the addition you always disregard the last carry, so our example would be:

which gives us 10000101, now we can convert this value into decimal, which gives 133_{10}

So the full calculation in decimal is**235**_{10} - 102_{10} = 133_{10} (correct!)

which gives us 10011010.

Now we need to add 11101011 + 10011010, however when you do the addition you always disregard the last carry, so our example would be:

which gives us 10000101, now we can convert this value into decimal, which gives 133

So the full calculation in decimal is

The above example is subtracting a smaller number from a larger number.

If you want to subtract a larger number from a smaller number (giving a negative result), then the process is slightly different.

Usually, to indicate a negative number, the most significant bit (left hand bit) is set to 1 and the remaining 7 digits are used to express the value. In this format the MSB is referred to as the sign bit.

Here are the steps for subtracting a large number from a smaller one (negative result)._{10} - 180_{10})

The process is as follows:

Now we can convert this value into a negative decimal, which gives -31_{10}

So, the full calculation in decimal is**149**_{10} - 180_{10} = -31_{10} (correct!)

If you want to subtract a larger number from a smaller number (giving a negative result), then the process is slightly different.

Usually, to indicate a negative number, the most significant bit (left hand bit) is set to 1 and the remaining 7 digits are used to express the value. In this format the MSB is referred to as the sign bit.

Here are the steps for subtracting a large number from a smaller one (negative result).

- Apply two's complement to the larger number.
- Add this value to the smaller number.
- Change the sign bit (MSB) to zero.
- Apply two's complement to value to get final result.
- The most significant bit (sign bit) now indicates the value is negative.

The process is as follows:

Now we can convert this value into a negative decimal, which gives -31

So, the full calculation in decimal is

Binary multiplication can be achieved in a similar fashion to multiplying decimal values.

Using the long multiplication method, ie, by multiplying each digit in turn and then adding the values together.

For example, lets do the following multiplication: 1011 x 111 (decimal 11_{10} x 7_{10})

which gives us 1001101, now we can convert this value into decimal, which gives 77_{10}

So the full calculation in decimal is 11_{10} x 7_{10} = 77_{10} (correct !!)

note:*Notice the pattern in the partial products, as you can see multiplying a binary value by two can be achieved by shifting the bits to the left and adding zeroes to the right.*

Using the long multiplication method, ie, by multiplying each digit in turn and then adding the values together.

For example, lets do the following multiplication: 1011 x 111 (decimal 11

which gives us 1001101, now we can convert this value into decimal, which gives 77

So the full calculation in decimal is 11

note:

Like multiplication, dividing binary values is the same as long division in decimal.

For example, lets do the following division: 1001 ÷ 11 (decimal 9_{10} ÷ 3_{10})

which gives us 0011, now we can convert this value into decimal, which gives 3_{10}

So the full calculation in decimal is 9_{10} ÷ 3_{10} = 3_{10} (correct!)

note:*Dividing a binary value by two can also be achieved by shifting the bits to the right and adding zeroes to the left.*

For example, lets do the following division: 1001 ÷ 11 (decimal 9

which gives us 0011, now we can convert this value into decimal, which gives 3

So the full calculation in decimal is 9

note:

advertisement

© Copyright 2014 HelpWithPCs.com