Sei sulla pagina 1di 35

MA 102 METHODS OF MATHEMATICS Discrete Mathematics Course Outline

Number Systems Number bases; the decimal, binary, octal and hexadecimal systems; calculating in the binary, octal and hexadecimal systems, converting between bases, representing fractions, negative numbers.

Sets Binary operations,Venn diagram, laws, applications.

Functions and sequences Ordered pairs, tree diagrams, relations and types, functions, sequences.

1.

Number Systems
Introduction
The history of mathematics began thousands of years ago with numbers and counting.Today numbers are more important in our lives than ever before with information in every field, from pin numbers and bar codes to music and television transmissions recorded digitally. In this section, we consider various ways in which numbers can be represented.

Number Bases
The Decimal Number System(Numbers in Base 10) Suppose that a ....a a a a represents a positive decimal number, where the symbols a ,..., a , a , a , a each represents one of the digits 0,1,2,..,9 (not necessarily different from one another). The following two methods give the actual value V of the number.
n 3 2 1 0 n 3 2 1

Method 1 We can think of each digit as appearing in a labeled box , where each box has a place value, according to its positions illustrated below.

The place value of each digit determines how much it contributes to the value of the number. . .
10 n

an

.. ..

10 3

10 2

101

10 0

a3

a2

a1

a0

The name decimal reflects the fact that every place value in our system is a power of 10. Note: The decimal system has base 10. The number a .....a a a a in expanded notation can be written as, V= a (10 ) + ............. + a (10 ) + a (10 ) + a (10 ) + a (1) .
n 3 2 1 0

Method 2 Double Bubble Method Step 1 Step 2 Step 3 Step 4 Example: Take V=a Multiply V by 10, Then V V *10 Add next digit, V V + nextdigit If not end go to step 2.
n

Suppose that a a a a represents a decimal number. Then we can write a a a a in expanded notation in the base 10, as
3 2 1 0 3 2 1 0

V = a3 (10 3 ) + a 2 (10 2 ) + a1 (101 ) + a 0

In Double Hubble method


V = ((((a3 * 10 + a 2 ) *10) + a1 ) * 10 + a 0

The Binary System Most modern computer systems operate using binary logic. A digital computer is just a collection of on/off switches, with an intricate set of connections between them. Thus the two positions of a switch are represented by digits 0 and 1. Therefore, the whole purpose of using binary notation is for constructing on/off circuits that can represent bit values in terms of two voltage values, either high or low. Binary numbers Definition: The number system with base 2 ,having just two digits 0and 1,is called the binary number system. Each binary digit is called a bit(short for binary digit.). A string of bits like 10001011 is called a binary string. To represent numbers in binary system the box system in binary as shown below is used giving the place value of each bit.
4

25

24

23

22

21

Conversion of Decimal to Binary To convert 15 to binary keep on dividing by 2 as follows. 2 15 2 7 2 3 -1 15 =


(1111) 2

- 1 - 1

The following table shows the binary equivalent of decimal numbers from 1 to 16. base 10
1 2 3 4 5 6 7

base 2
(1) 2
(10) 2 (11) 2 (100) 2 (101) 2 (110) 2 (111) 2

base 10
9 10 11 12 13 14 15

base 2
(1001) 2 (1010) 2 (1011) 2 (1100) 2 (1101) 2 (1110) 2 (1111) 2

(1000) 2

16

(10000) 2

Conversion of Binary to Decimal Just like the decimal system, each digit is multiplied by its weighted position, and add each of the weighted values together. Example Convert the binary integer system.
26 25
0 (1001011) 2

to the decimal
22
0

24
0

23

21

1
1

When finding the decimal equivalent of a binary number, it is easy to work from right to left.
(1001011) 2 = 1(1) + 1(21 ) + 0(2 2 ) + 1(2 3 ) + 0(2 4 ) + 0(2 5 ) + 1(2 6 )

= 1 + 21 + 2 3 + 2 6
= 75

In Double Bubble method,


(1001011) 2 = (((((1 * 2 + 0) * 2 + 0) * 2 + 1) * 2 + 0) * 2 + 1) * 2 + 1

Consider the binary number (a a a a a ) where each of the symbols a represents a bit (0 or 1). When converted to Decimal it is equal to ,
4 3 2 1 0 2

a 4 (2 4 ) + a3 (2 3 ) + a 2 (2 2 ) + a1 (21 ) + a0 (1)

in expanded

notation. Ex: Use Double Bubble Method also. Exercise: Convert the following binary numbers to decimal. (i) 110101 (ii) 11100011 (iii)101110001 Calculating in the Binary System Binary Addition In the decimal system when we add a column of digits that sum to a number greater than 9,units in the column that we are working in are recorded and carry the number of 10s into the next column to the left. We proceed in a very similar way in binary. The rules for addition (1) (2)
( 0) 2 + ( 0) 2 = ( 0) 2 (0) 2 + (1) 2 = (1) 2 = (1) 2 + (0) 2

To obtain rules for carrying, suppose the column to be added is as follows. (3)
(1) 2 + (1) 2 = (10) 2

(since 1+1= 2)

Record the zero in the current column and carry 1 to the next column to the left. (4)
(1) 2 + (1) 2 + (1) 2 = (11) 2

(since 1+1+1=3)

Record 1 in the current column and carry 1 to the next column to the left. (5)
(1) 2 + (1) 2 + (1) 2 + (1) 2 = (100) 2

Record 0 in the current column and carry 1 to the column two places to the left. Example: Find the sum of the binary numbers
(1011) 2 + (1111) 2 + (11) 2 .

In the format below ,the numbers we carry at each step are recorded above the horizontal line. Step 1: 1 10 1 1 11 1 1 11 1 Step 2: 1 1 1011 1111 11 Adding the right hand column we obtain (11) and so we record 1 and carry 1 into the next column (that is 2 column).
2 1

Adding the 2 column, we obtain (100) and so we record 0 and carry 1 into the column two places left (that is the 2 column)
1 2 3

01

Step 3: 11 1 1011 1111 11 1 1101

Adding 2 column we obtain (1) ,so this time nothing to carry.Adding the 2 column we obtain (11) so we record 1 and carry 1 into 2 column. Adding 2 column we obtain (1) and process terminates.
2 2 3 2 4 4 2 2 2 2 2

Thus we obtain (1011) + (1111) + (11) = (11101) . In decimal numbers , this addition is 11+15+3=29. Exercise: Perform following binary additions (i) 11111 + 111 (iii) 11001 + 11 Check your answers by converting to decimal. Binary Subtraction To evaluate 123-36 we must borrow a 10. We shall now carry out the same process in binary, where we have to borrow a 2 when we have to perform the subtraction (0) (1) in any column.
2 2

(ii) 100110 + 101010

To obtain the rules for borrowing, suppose the column to be subtracted is as follows. 1. 2. 3. 4.
( 0) 2 ( 0) 2 = ( 0) 2
(1) 2 (0) 2 = (1) 2 (1) 2 (1) 2 = (0) 2

after borrowing 1 from left of bigger number. i.e. It becomes (10) (1) .
(0) 2 (1) 2 = (1) 2
2 2

Example: Subtract Step 1: We have to borrow to perform the subtraction in the units column.The first column with a non zero entry is the 2 column. We borrow (1000) from this column. The revised row is recorded above the horizontal line.
3

(1101000) 2 (101011) 2 .

11001110 110100 0 10101 1

(2

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

Step 2: 10110 110 01110 10 101 1


10

10 1 Step 3: 010 1 01101110 10 101 1 1 110 1 Thus (11010000) (101011) = (111101) . In decimal 104 43 = 61.
2 2 2

Exercise: Perform following binary subtractions. (i) 1111-111 (ii) 11001-101 (iii) 100001-11 Check your answers by converting to decimal. Binary Multiplication The process of binary multiplication is very similar to long multiplication in the decimal system. Example: Multiply 1011 101 1011 10110 110111
(1011) 2 x(101) 2

11

Check whether this is correct by finding the decimal equivalent. Exercise: Perform the following binary multiplications. (i) 1111 x 1101 (ii) 1011 x 111 (iii) 11011 x 11101 Check your answers by converting to decimal. A familiar feature in decimal is that when we multiply any whole number by 10, we move all the digits one place to the left and enter a zero in the units column.

Consider 743 x 10. Writing 743 in expanded notation, 743 = 7(10 ) + 4(10 ) + 3(1). 743 x 10 = 7(10 ) + 4(10 ) + 3(10 ) + 0(1) Thus the place value of each digit has been multiplied by 10 and the entry in the units column is now 0.
2 1 3 2 1

A similar thing happens when we multiply binary number by the base number 2= (10)
2

12

Now consider

(a 4 a3 a 2 a1 a o ) 2 x 2

(a 4 a3 a 2 a1 a o ) 2 = a 4 (2 4 ) + a3 (2 3 ) + a 2 (2 2 ) + a1 (21 ) + a0 (1) (a 4 a3 a 2 a1 ao ) x 2

a 4 (2 5 ) + a3 (2 4 ) + a 2 (2 3 ) + a1 (2 2 ) + a 0 (21 ) + 0(1)

Thus the place value of each bit has been multiplied by 2 and so the bits all move one place to the left and the entry in the units column is 0.

RULE : To multiply by (10) in binary , we move each bit one place to the left and enter 0 in the 2 column.
2 0

This rule can be extended to multiply by any power of 2. For example multiply by 4 is multiply by 2 and again multiply the result by 2. So we move each bit two places to the left and enter zeros in both the 2 Column and 2 columns. Thus the rule for multiplying by 4 = (100) in binary is exactly the same as the rule for multiplying by 100 in decimal.
1 0 2

Exercise: Perform following binary multiplications.


13

(i) 1011 x 10 (ii) 11011 x 100 Check your answers by converting to decimal. Binary division The process of long division in the binary system is very similar to long division in the decimal system. Key operations are, 0/1=0 and 1/1=1. Example: Calculate (101001) 1101 11 101001 11 100 11 101 11 10

/(11) 2

(101001) 2 /(11) 2 = (1101) 2

with with

remainder In decimal remainder

(10) 2 . 41 / 3 = 13

2.

Exercise Perform following binary divisions. (i) 101100 / 101 (iii) 100110 / 110 Check your answers by converting to decimal. Note: (ii) 1001110 / 111

14

Dividing by 2 is just the reverse of the process of multiplying by 2 . Therefore the following rule applies. Rule To divide by (10) in binary we move each bit one place to the right and the entry in the unit column becomes the remainder.
2

Example
(110111) 2 /(10) 2 = (11011) 2

The divisor is Exercise

(10) 2

, remainder (1) . and quotient is


2

(11011) 2 .

Perform the following binary divisions (i) 101100 / 100 (ii) 1001110 / 10 Check your answers by converting to decimal. Conversion of Decimal to binary Method 2 For this method , divide the decimal number by 2, if the remainder is 0, on the side write down a 0. If the remainder is 1,write down a 1. This process is continued by dividing the quotient by 2

15

and dropping the previous remainder until the quotient is 0. Step 1 - Divide decimal number by 2 , giving quotient Q , remainder R .
1 1

Step 2 - Divide last quotient remainder R . Step 3 - If last


Q 0, go

QL

by giving

and

to 2
3 2 1

Step 4 - Binary number, b=.. R R R Example:

Convert the decimal number 2671 to binary. Division 2671/2 1335/2 667/2 333/2 166/2 83/2 41/2 20/2 10/2 5/2 2/2 Quotient 1335 667 333 166 83 41 20 10 5 2 1 Remainder 1 1 1 1 0 1 1 1 0 1 0 Binary number 1 11 111 1111 01111 101111 1101111 01101111 001101111 1001101111 01001101111
16

1/2

0 1 101001101111 Exercise: Convert the following decimal numbers to binary (i) 24 (ii) 282 (iii) 5731 Octal number system The octal system is based on the binary system with a 3-bit boundary. The octal number system uses base 8 and include only the digits through 0 and 7. Arithmatic in Octal Octal arithmetic is very similar to decimal arithmetic. Here we carry or borrow 8s instead of 10s. Octal or decimal Conversion To convert from Octal to Decimal, multiply the value in each position by its octal weight and add each value. Example: Convert the octal number decimal.
82
5

(547) 8

to

81

1
7

(547) = 5(8 2 ) + 4(81 ) + 7(1) = 383

17

Binary to Octal conversion It is easy to convert from an integer binary number to Octal. This is accomplished by (i)Break the binary number into 3-bit sections from the bit in the units column and working to the left. (ii) Convert the 3-bit binary number to its octal equivalent. In the following table you will see that each binary number is expressed as a 3-bit string, by adding zero where necessary at the front of each binary number to make up the total number of bits to three. Octal 3-bit bina ry
(0) 8
(000) 2

(1) 8
(001) 2

( 2) 8
(010) 2

(3) 8
(011) 2

(4) 8
(100) 2

(5) 8
(101) 2

(6

(1

Example: Express the binary number Octal number.


(1010111110110010) 2 = (127662) 8

(1010111110110010) 2

as an

1010111110110010=001 010 111 110 110 010 Exercise: Express the following binary numbers as octal numbers.
18

(i)

(111001100) 2

(ii)

(11001010110) 2

Octal to binary Conversion It is also easy to convert from an integer octal number to binary using the following. 1. Convert the decimal number to its 3-bit binary equivalent. 2. Combine the 3-bit sections removing the spaces. Example Express the octal value (127662) as binary. 127662= 001 010 111 110 110 010
8

(127662) 8 = (001010111110110010) 2

Exercise Express following octal values in binary. (i) (264) (ii) (1456)
8 8

Conversion of Decimal to Octal As in the binary conversion decimal number is repeatedly divided by 8 and remainders were recorded.

19

Example Express the decimal number44978 as an octal Number.

Division 44978/8 5622/8 702/8 87/8 10/8 1/8

Quotient 5622 702 87 10 1 0

Remainder 2

Octal Num ber 2

6 62 6 662 7 7662 2 2766 2 1 1276 62

Exercise Express following decimal numbers as octal numbers. (i) 684 (ii) 9251

20

The Hexadecimal Number System To represent large numbers the binary system requires more digits. The hexadecimal system based on 16 solves this problem and it has the following advantages. 1. It enables most numbers to be recorded using Substantially fewer digits than are necessary in base 2. 2. There is a very easy method of converting between hexadecimal and binary. The hexadecimal system is based on the binary system using a 4-bit boundary. In order to express a number in the hexadecimal system we need 16 digits. The digits 0,1,..,9 followed by the letters A,B,C,D,E and F are used. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Hex0 1 2 3 4 5 6 7 8 9 A B C D E F decimal

The hexadecimal digits are known as hexits and hexadecimal system is often called hex. Hex to Decimal Conversion

21

To convert from Hex to Decimal multiply the value in each position by its hex weight and add each value. Example Convert the hex number
(5 AE 7)16

to decimal.

16 3

16 2

161

5 Or

(5 AE 7)16 = 5(16 3 ) + 10(16 2 ) + 14(161 ) + 7(1) = 23711.

(((5 *16 + 10) *16 + 14) *16 + 7 = 23711

Arithmatic in Hex Hexadecimal arithmetic is very similar to decimal arithmetic, except that we have 16 hexits and carry or borrow 16s instead of 10s. Example
(9 D7)16 + (4 BA)16

Hexits we carry are entered in the row above the horizontal line. 11 9D7

(9 D7)16 + (4 BA)16 = ( E 91)16

22

4BA E91

In decimal 2519+1210=3729

Example
( F 04)16 (CD9)16

EF14 F04 CD9 22B Decimal Fractions

( F 04)16 (CD9)16 = (22 B)16

In decimal, 3844-3289=555

To represent a rational number in base 10 in expanded notation, the place values as illustrated below are used.

The decimal expansion of a fraction either terminates after a finite number of places or has a recurring block of figures.

23

Example 17/20=0.85 and 3/8 = 0.375 5/12=0.416666.. digit 6 has recurred 7/11 = 0.636363 recurring block of figures. Suppose we are given a terminating or repeating decimal . The following method is used to express it as a fraction m/n , where m and n are integers. Example Express the repeating decimals 0.272727. as a fraction of its lowest terms. Step 1 Determine the number of digits in the repeating block. In this case the repeating block is 27 and the number of digits is 2. Step2 Write x = 0.272727............. and multiply x by 10 where the power of 10 is the length of the repeating block. This gives 100 x = 27.272727.
2

Step 3

24

Subtract x

from 100x 27.272727 0.272727. 27.000000.

100x = x = 99x = Step 4

Solve the equation to find x. 99x=27 x = 27/99 = 3/11. Example Express the repeating decimals 0.15333.. as a fraction of its lowest terms. In this case, repeating block is single digit 3 and number of digits is 1. Let x = 0.153333.. 10x = 1.53333 x = 0.15333. 9x = 1.38 x = 1.38 / 9 = 138/900 = 23/150. Result The rational numbers are those numbers that can be represented as a terminating or recurring decimal. Fractions in base other than 10

25

The place values in the full binary system are as follows. .


24 23 22 21 1 2 1 2 2 2 3 2 4

..

Example Express the binary number


1

(0.1101) 2 in

base 10.

1(2 ) + 1(2 2 ) + 0(2 3 ) + 1(2 4 ) = 1 / 2 + 1 / 4 + 1 / 16 = 0.8125

An alternative method is first express (0.1101) as a binary fraction , and then convert both the numerator and the denominator to base 10.
2

13 1101 = 0.8125 (0.1101) 2 = = 10000 2 16

Example Express the binary number


2 1

(101.11) 2
0

in 10.
2

1(2 ) + 0(2 ) + 1(1) + 1(2 ) + 1(2 ) = 2 + 2 + 2 + 2


2

= 5.75

Alternatively,
(101.11) 2 = (101) 2 + (11 / 100) 2 = 5 + 3 / 4

= 5.75

The part with digits to the left of the point is called the integral part of the number and the part with digits to the right of the point is called fractional part of the number. Thus the integral part of (101.11) is (101)
2 2

26

And the fractional part is Octal system

(0.11) 2

The place values in the full octal system are as follows: .


84 83 82 81 1 8 1 8 2 8 3 8 4

Example Express the octal number


1(81 ) + 3(1) + 4(8 1 ) = 11 + 1 / 2 = 11.5

(13.4) 8

in base 10.

Hexadecimal system The place values in the full hexadecimal system are as in the octal system where 8 is replaced by 16. Example Express the number
( E 7.3B)16

in base 10.

14(161 ) + 7(1) + 3(16 1 ) + 11(16 2 ) = 231 + 3 / 16 + 11 / 256

Note To convert the fractional part of a binary number into the hexadecimal system first split the binary string into groups of four bits starting from the decimal point and working to the right. If the last
27

block to the right contains less than four bits , add zeros as necessary and use the binary hex conversion table. Negative number representation Following methods are available to store negative numbers. All numbers are assumed to be stored in binary form. It is important to work with the word length of the machine. Word length is the number of bits required to represent a number. For example if 16 bits are used to represent an integer in a particular computer then we say that the machine has word length 16. Signed Bit Magnitude Representation Here, The first binary digit(left most bit) represents the sign. 0 for positive and 1 for negative numbers. Example Assume 4 bit computer word and represent decimal integers +7, -7 in binary.
(111) 2 = 710

(positive)

Extra bit representing sign, ( 0-positive,1negative)


28

01112 = 710

( positive)

Extra bit representing sign, 1111 = 7 (negative)


2 10

Exercise Assume 8 bit computer word and represent the following decimal integers in binary. (a) 48 (b) 48 (c) 27 Ones complement and Twos complement Representations 1. Represent the magnitude of the binary in the given word length. (You may add zeros in front to fill blanks) 2. Complement each digit by flipping 1 to 0 and 0 to 1. This is called ones complement of the given number. 3. Add 1 to ones complement representation. This is called twos complement representation. With this strategy ,we assign the leftmost bit to serve a special purpose ,just as we did with the sign magnitude approach, defining our number limits as before. However , this time the leftmost bit is more than just a sign bit, rather it possesses a negative place-weight value.

29

Example Represent the value of the negative five using twos complement.
10112

- twos complement of negative 5

10112 = (1x 810 ) + (0 x 410 ) + (1x 210 ) + (1x110 ) = 510

With the right 3 bits being able to represent a magnitude from zero through seven and the leftmost bit representing either zero or negative eight , we can represent any integer from negative seven to positive seven. Since,
10012 = 810 + 110 = 710 01112 = 010 + 710 = 710

Representing positive numbers in this scheme (with the fourth bit designated as the negative weight) is no different from that of ordinary binary notation. zero 0000 positive one 0001 positive two 0010 positive three 0011 positive four 0100 positive five 0101 positive six 0110 positive seven 0111 negative one 1111 negative two 1110 negative three 1101 negative four 1100 negative five 1011 negative six 1010 negative seven 1001 negative eight 1000

30

Exercise: Represent in twos complement format as 8 bit word length. (a) 47 (b) -44
Binary subtraction by twos complement To calculate a-b, both in binary, 1. Represent the magnitude of the binary in the given word length. 2. Write 2s complement of b as b

3. Find

a + b

BCD(Binary Coded Decimal) Number System If we view single digit values for hex, the numbers 0-F , they represent the values 0-15 in decimal. This system is used for some purposes where each digit of a decimal number is converted to binary form. For this , since digits 0 to 9 are to be converted to binary, 4 binary bits are required to represent each digit. To represent a decimal number beyond 9 two or more decimal digits are needed that is BCD representation requires 2 or more 4-bit groups.

31

BCD is just a code in binary, as opposed to a straight binary number ,which represents the actual value. The table below shows the binary and the BCD equivalents of decimals 0 through 15. Decimal 0 1 2 3 . . 10 11 12 13 14 15 Binary 0000 0001 0010 0011 . . 1010 1011 1100 1101 1110 1111 BCD 0000 0001 0010 0011 . . 0001 0000 0001 0001 0001 0010 0001 0011 0001 0100 0001 0101

Decimal to BCD conversion Each decimal digit is independently represented by its corresponding binary. 3 7 2 9

0011

0111 0010 1001

32

BCD to Decimal conversion


Starting from right , partition the binary pattern into groups of 4 bits each. Each group is then converted to its corresponding decimal number. Example Convert to decimal.

(1001001101010001) BCD

1001 0001 0101 0001

9 3 5 1 Equivalent decimal number is

(9351)10

Exercise: (i) Convert the following numbers to BCD. (ii) (a) (362) (b) (47.28) (c) (7 AF .2C ) Convert the following BCD binary numbers to decimal. (a) 100000100 (b) 11101011001.10011
10 10 16

Exercises 1. Write the decimal numbers 4037 and 40371 in expanded form as multiples of 10. 2. Express the following binary numbers as
33

decimal numbers. (a)


(11011) 2

(b)

(1100110) 2

(c)

(111111111) 2

3. Perform the binary additions. (a)


(10111) 2

(b)

(1101) 2 + (1011) 2 + (1111) 2

4. Perform the binary subtractions. (a)


(1001) 2 (111)

(b)

(110000) 2 (10111) 2

5. Perform the binary multiplications. (a)


(1101) 2 x(111) 2

(b)

(1101) 2 x(1101) 2

6. Perform the binary division.


(111011) 2 /(101) 2

7. (a) Write the octal number (227) in binary. (b) Write the binary number (10111011100) in octal system. (c ) Write the hex number ( EC 4) in binary. (d) Write the binary number (1111011010) in hex. 8. Perform following calculations.
8 2 16 2

(a) (b)

(123) 8 + (107) 8 (234.72) 8 + (10.4) 8

and and

(123) 8 (107) 8 (234.72) 8 (10.4) 8

34

9. Perform following calculations. (a) ( BC.7) + (77.7) (b) ( BC.7) (7.2) 10.Represent the following numbers in signed bit magnitude format and in twos complement format as 16 bit word length.
16 8 16 8

(a) 47 (b) -44 11.Perform the following subtractions using twos complement method. (a)
(1001) 2 (111) 2

(b)

(110000) 2 (10111) 2

35

Potrebbero piacerti anche