0% found this document useful (0 votes)
1 views

Binary Numbers

The document explains number systems, focusing on the decimal and binary systems, including their structure and conversion methods. It covers addition and subtraction in both systems, as well as concepts like one's complement and two's complement for representing negative numbers. Exercises are provided for practice in converting between decimal and binary, and performing arithmetic operations.

Uploaded by

rockerandrew
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Binary Numbers

The document explains number systems, focusing on the decimal and binary systems, including their structure and conversion methods. It covers addition and subtraction in both systems, as well as concepts like one's complement and two's complement for representing negative numbers. Exercises are provided for practice in converting between decimal and binary, and performing arithmetic operations.

Uploaded by

rockerandrew
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Number Systems

The Decimal System


When you count you use the numbers 0, 1, 2, 3, 4, 5, 6,
7, 8, 9, etc. The decimal number system has ten digits:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9. But what happens after 9?

You set the unit number back to zero and add a 1 in the
tens place. When you get to 19, you set the unit number
back to zero and change the tens digit to 2. Similarly
when you get to 99, you must change the units and the
tens to 0. Then, you add a one in the hundreds place to
get 100.

So what is happening? Let’s look at the number 3427.

Thousands Hundreds Tens Units


3 4 2 7

Or,

3 x 1000 + 4 x 100 + 2 x 10 + 7 x 1

But

1000 = 10 x 10 x 10 = 103
100 = 10 x 10 = 102
10 = 101
1 = 100
(You can check this on your calculator)

So,
3427 = 3 x 103 + 4 x 102 + 2 x 101 + 7 x 100

(You can check this on your calculator too)

But what about other number systems? Let’s have a look


at the binary system.

1
The Binary System
The binary system has only 2 digits: 0 and 1. In binary,
the first digit is 0 and the second digit is 1. But what
happens next? Well in the decimal system, when you get
to 9, you put a 0 in the units place and a one in the tens
place. Similarly, when you get to 1 in binary the next
number is 10. The next number is then 11. What do you
think comes next?

Let’s look at some decimal numbers in binary:

A binary number is written with a subscript 2 to


distinguish it from a decimal number. So, the binary
number 11 is written as 112.

Two to the Power of


Binary numbers are base 2 numbers.

2n Total
20 1
21 2
22
23
24
25
26
27
28
29

2
Converting from Binary to Decimal
Remember that:

3427 = 3 x 103 + 4 x 102 + 2 x 101 + 7 x 100

Similarly,

1111 = 1 x 23 + 1 x 22 + 1 x 21 + 1 x 20

=1x8+1x4+1x2+1x1

=8+4+2+1

=15

So, the binary number 1111 is equivalent to the decimal


number 15.

And:
100110 = 1 x 25 + 0 x 24 + 0 x 23 + 1 x 22 + 1 x 21 + 0
x 24

= 32 + 4 + 2

= 38

Exercise
Convert the following binary numbers to decimal form.

(i) 1102
(ii) 110012
(iii) 1010112
(iv) 11102
(v) 110112
(vi) 10000012
(vii) 11100112
(viii) 101112
(ix) 10010102
(x) 110011002

3
Converting from Decimal to Binary
Converting from decimal to binary involves repeatedly
dividing by 2 until you get 0.

Example
Convert 15610 to binary.

2|156 Remainder
2|78 0
2|39 0
2|19 1
2|9 1
2|4 1
2|2 0
2|1 0
1 Binary number: 100111002

Exercise
Convert the following decimal numbers to binary form.

(i) 12
(ii) 62
(iii) 128
(iv) 248
(v) 572
(vi) 891
(vii) 945
(viii) 1202
(ix) 1668
(x) 14772

Check your answer by converting the number back to


decimal form.

4
Adding Decimals
To add a decimal, you write one number on top of the
other number. Then, you add the numbers in each
column staring on the right.

Example
Add the numbers 32 and 49.

First, add the two numbers in the right-hand column.

320
493
3

Then, add the two numbers in the next column. 9 plus 2


is greater than ten so you write down 1 and carry 1.

3 20
4193
13

Then, add the numbers in the leftmost column.

3 20
4193
713

Adding Binary Numbers


Adding binary numbers is similar.

Example
Add 1112 and 1002

111
100

5
First, add the rightmost column: 1 + 0 = 1, which is a
binary number.

111
100
1

Similarly, add the second column. Again, 1 + 0 = 1

111
100
11

Then, add the leftmost column. 1 + 1 = 10

111
100
1011

Let’s convert the numbers to decimals


and see if we are right.

1112 = 1 x 22 + 1 x 21 + 1 x 20 = 7

1002 = 1 x 22 + 0 x 21 + 0 x 20 = 4

7 + 4 = 11

10112 = 1 x 23 + 0 x 22 + 1 x 21 + 1 x 20 = 11

Therefore,

111
100
1011 Q.E.D.

Exercise
Add the following binary numbers
(i) 11 + 101
(ii) 101 + 100

6
(iii) 1110 + 1010
(iv) 1000 + 101
(v) 10010 + 1100
(vi) 1011101 + 1000000
(vii) 10011 + 1111101
(viii) 10011001 + 100111
(ix) 11000011 + 10111
(x) 100110 + 1100101

Ones Complement
1s complement is calculated by changing all the 1s in a
binary number to 0 and converting all the 0s to 1.

Example
Find the 1s complement of the following numbers.
(i) 001
(ii) 010
(iii) 000
(iv) 0101
(v) 0011
(vi) 0111
(vii) 01110100
(viii) 00001111
(ix) 01010000
(x) 00101010

Negative Binary Numbers


1s complement can be used to find the negative of a
binary number.

Example
Let’s find -310 in binary.

We know that 310 = 011 in three-bit format

7
Therefore, -310 = 100 (just change all the 0s to 1s and
1s to 0s).

Exercise
Using 8-bit format, convert all the following decimal
numbers to binary form.
(i) -2
(ii) -1
(iii) -6
(iv) -7
(v) -11
(vi) -12
(vii) -15
(viii) -18
(ix) -20
(x) -25

Twos Complement
Two complement is used by computers to represent
negative numbers. To get the two's complement
negative notation of an integer, you write out the
number in binary. You then invert the digits, and add
one to the result.

Example
Find the twos complement of the following 8-bit number.

00010001

Change all the 1s to 0s and all the 0s to 1 and add 1 to


get.

11101110 + 1 = 11101111

The twos complement of 00010001 is 11101111.

8
Exercise
Find the twos complement of the following numbers.

(i) 001
(ii) 010
(iii) 011
(iv) 0101
(v) 0010
(vi) 0111
(vii) 01110100
(viii) 00001111
(ix) 01010000
(x) 00101010

Negative Numbers
Suppose we’re working in 8-bit format and want to
change the integer -28 to binary. First write 28 in 8-bit
binary form.

2810 = 00011100

Now find the twos complement of 00011100

= 11100011 + 1 = 11100100

So, -2810 = 111001002

Exercise
(i) -3
(ii) -4
(iii) -5
(iv) -9
(v) -10
(vi) -11
(vii) -14
(viii) -16
(ix) -21
(x) -22

9
Binary Addition Reviewed
Let’s look at binary addition again.

Example
Add the decimal numbers 68 and 11 in binary form.

6810 = 01000100

1110 = 00001011

01000100
+00001011
01001111

Let’s check this 68 + 11 = 79

And 010011112

= 2 7 x 0 + 26 x 1 + 2 5 x 0 + 24 x 0 + 23 x 1 + 2 2 x 1 +
2 1 x 1 + 20 x 1

= 0 + 64 + 0 + 0 + 8 + 4 + 2 + 1

= 79

Exercise
Add the following decimal numbers in binary form.
Check your answer by converting back to decimal form.
(i) 3 + 12
(ii) 7+9
(iii) 8 + 11
(iv) 14 + 17
(v) 15 + 19
(vi) 20 + 8
(vii) 22 + 15
(viii) 23 + 16
(ix) 24 + 10
(x) 30 + 11

10
Binary Subtraction
What happens if you want to subtract? Let’s look at 68 –
11.

01000100
-00001011

Rather than subtracting 11, we can change 11 to


negative form using twos complement and then add it.

Example
11 = 00001011

-11 = 11110101

68 + (-11) =

01000100
11110101
100111001

We have an extra digit here 100111001


In twos complement we just delete it. Let’s check our
answer.

68 – 11 = 57

001110012 = 27 x 0 + 26 x 0 + 25 x 1 + 24 x 1 + 23 x 1
+ 2 2 x 0 + 21 x 0 + 2 0 x 1

= 0 + 0 + 32 + 16 + 8 + 0 + 0 + 1

= 57

Exercise
Add the following decimal numbers in binary form.
Check your answer by converting back to decimal form.
(i) 12 - 3

11
(ii) 8-2
(iii) 9-5
(iv) 17 - 11
(v) 15 - 4
(vi) 19 - 12
(vii) 16 - 8
(viii) 25 - 15
(ix) 43 - 20
(x) 52 – 18

Converting From Twos Complement


To convert from twos complement, change the 0s to 1s
and the 1s to 0s and add 1.

Example
10011001 = 01100110 + 1 = 01100111

Exercise
Convert these numbers from twos complement.
(i) 11001001
(ii) 11100000
(iii) 10111111
(iv) 10000110
(v) 11000000

Positive and Negative Numbers


In two's complement, a leading 1 means the number is
negative, a leading 0 means the number is positive.

Example
01000100 - this is a positive number.

11110101 – this is a negative number.

12
Exercise
Are the following numbers negative or positive?

(i) 11000111 –
(ii) 01110100 –
(iii) 10111100 –
(iv) 00000111 –
(v) 01100110 –

13

You might also like