8 - number system

Post on 30-Aug-2014

203 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1

Number Systems

Base 2: The Binary Number SystemBase 8: The Octal Number SystemBase 16: The Hexadecimal Number System

2

Number Base• What is a number base?

A number base is a specific collection of symbols on which a number system can be built.

• The number base familiar to us is base 10, upon which the decimal number system is built. There are ten symbols - 0 to 9 - used in the decimal system.

3

Place Value• What is the concept of place value?

Place value means that the value of a digit in a number depends not only on its own natural value but also on its location in the number.It is used interchangeably with the term positional notation.

• Place value tells us that the two 4s in the number 3474 have different values, that is, 400and 4, respectively.

4

A Review of the Decimal Number System• The word “decimal” comes from the Latin word

decem, meaning ten.• Thus, the number base of the decimal number

system is base 10.• Since it is in base 10, ten symbols are used in

the decimal number system.{0,1,2,3,4,5,6,7,8,9}

• This means that only the digits in the above set can be used for each position in every placevalue in a given decimal number.

5

A Review of the Decimal Number System

• Note that the highlighted place value can be filled by the digits in the set {0,1,2,3,4,5,6,7,8,9}.

• Thus, it can be increased by 1 until it reaches -

• At this point, the symbols that can be used to fill the highlighted position has been exhausted. Increasing it further causes a shift in place value, and resets the initial place value to zero. Thus -

2 7 0

2 7 9

2 8 0

6

A Review of the Decimal Number System• Case Study: 3474 • Using place values, the number 3474 is

understood to mean,3000 + 400 + 70 + 4 = 3474

This can also be expressed as –(3x1000) + (4x100) + (7x10) + 4 = 3474

Note that each digit is multiplied by powers of 10, so that the above is equal to –

(3x103) + (4x102) + (7x101) + (4x100) = 3474Note that the rightmost exponent starts from zero and increases by 1 as the place value increases.Hence, the decimal number system is said to be in base 10.

7

Base 2: The Binary Number System• The word “binary” comes from the Latin word

bis, meaning double.• Thus, the number base of the binary number

system is base 2.• Since it is in base 2, two symbols are used in the

binary number system.{0,1}

• This means that only the digits in the above set can be used for each position in every placevalue in a given binary number.

8

Base 2: The Binary Number System

• Note that the highlighted place value can be filled by the digits in the set {0,1}.

• Thus, it can be increased by 1 until it reaches -

• At this point, the symbols that can be used to fill the highlighted position has been exhausted. Increasing it further causes a shift in place value, and resets the initial place value to zero. Thus -

1 1 0

1 1 1

1 1 0

0

0

1

9

Base 2: The Binary Number System• To avoid confusion, one should write a binary

number with base 2 as its subscript whenever necessary.

• Thus, the binary number 10110 should be written as -

101102

• It should be read as “one-zero-one-one-zero base two” and NOT “ten-thousand one-hundred ten” since each phrase denotes an entirely different number.

10

Base 2: The Binary Number System• Case Study: 101102 • We know that the decimal number 3474 can be

expressed as powers of 10 –(3x103) + (4x102) + (7x101) + (4x100) = 347410

• In the same manner, the binary number 101102 can be expressed as powers of 2 –

(1x24) + (0x23) + (1x22) + (1x21) + (0x20) = 2210

Note that the rightmost exponent starts from zero and increases by 1 as the place value increases.Hence, the binary number system is said to be in base 2.

11

Base 8: The Octal Number System• The word “octal” comes from the Greek word

oktõ, meaning eight.• Thus, the number base of the octal number

system is base 8.• Since it is in base 8, eight symbols are used in

the octal number system.{0,1,2,3,4,5,6,7}

• This means that only the digits in the above set can be used for each position in every placevalue in a given octal number.

12

Base 8: The Octal Number System

• Note that the highlighted place value can be filled by the digits in the set {0,1,2,3,4,5,6,7}.

• Thus, it can be increased by 1 until it reaches -

• At this point, the symbols that can be used to fill the highlighted position has been exhausted. Increasing it further causes a shift in place value, and resets the initial place value to zero. Thus -

3 6 0

3 6 7

3 7 0

13

Base 8: The Octal Number System• To avoid confusion, one should write an octal

number with base 8 as its subscript whenever necessary.

• Thus, the octal number 72143 should be written as -

721438

• It should be read as “seven-two-one-four-three base eight” and NOT “seventy two-thousand one-hundred forty three” since each phrase denotes an entirely different number.

14

Base 8: The Octal Number System• Case Study: 721438 • We know that the decimal number 3474 can be

expressed as powers of 10 –(3x103) + (4x102) + (7x101) + (4x100) = 347410

• In the same manner, the octal number 721438 can be expressed as powers of 8 –(7x84) + (2x83) + (1x82) + (4x81) + (3x80) = 2979510

Note that the rightmost exponent starts from zero and increases by 1 as the place value increases.Hence, the octal number system is said to be in base 8.

15

Base 16: The Hexadecimal Number System

• The word “hexadecimal” is a combination of the Greek word hex, meaning six and the Latin word decem, meaning ten.

• Thus, the number base of the hexadecimal number system is base 16.

• Since it is in base 16, sixteen symbols are used in the hexadecimal number system.

{0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}• This means that only the digits in the above set

can be used for each position in every placevalue in a given hexadecimal number.

16

Base 16: The Hexadecimal Number System

• Note that the highlighted place value can be filled by the digits in the set {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}.

• Thus, it can be increased by 1 until it reaches -

• At this point, the symbols that can be used to fill the highlighted position has been exhausted. Increasing it further causes a shift in place value, and resets the initial place value to zero. Thus -

A 3 0

A 3 F

A C3

B

B

0

17

Base 16: The Hexadecimal Number System

• To avoid confusion, one should write a hexadecimal number with base 16 as its subscript whenever necessary.

• Thus, the hexadecimal number B23C should be written as -

B23C16

• It should be read as “b-two-three-c base sixteen”.

18

Base 16: The Hexadecimal Number System

• Case Study: B23C16 • We know that the decimal number 3474 can be

expressed as powers of 10 –(3x103) + (4x102) + (7x101) + (4x100) = 347410

• In the same manner, the hexadecimal number B23C16 can be expressed as powers of 16 –

(11x163) + (2x162) + (3x161) + (12x160) = 4562810

Note that the rightmost exponent starts from zero and increases by 1 as the place value increases.Hence, the hexadecimal number system is said to be in base 16.

19

Comparative Values: Bases 10, 2, 8, 16

Base 10 Base 2 Base 8 Base 16Decimal Binary Octal Hexadecim

al0 0000 0 01 0001 1 12 0010 2 23 0011 3 34 0100 4 45 0101 5 56 0110 6 67 0111 7 78 1000 10 8

20

Comparative Values: Bases 10, 2, 8, 16

Base 10 Base 2 Base 8 Base 16Decimal Binary Octal Hexadecim

al9 1001 11 9

10 1010 12 A11 1011 13 B12 1100 14 C13 1101 15 D14 1110 16 E15 1111 17 F16 10000 20 1017 10001 21 11

21

Conversion from Bases 2, 8, 16 to Base 10

• Technique: Expand the number using the appropriate base.

• Convert 110102 to base 10.(1x24) + (1x23) + (0x22) + (1x21) + (0x20) = ?(1x16) + (1x8) + (0x4) + (1x2) + (0x1) = ?16 + 8 + 0 + 2 + 0 = 2610

• Convert 15378 to base 10.(1x83) + (5x82) + (3x81) + (7x80) = ?(1x512) + (5x64) + (3x8) + (7x1) = ?(512) + (320) + (24) + (7) = 86310

22

Conversion from Bases 2, 8, 16 to Base 10

• Technique: Expand the number using the appropriate base.

• Convert AF416 to base 10.(Ax162) + (Fx161) + (4x160)= ?(10x256) + (15x16) + (4x1) = ?2560 + 240 + 4 = 280410

23

Conversion from Base 10 to Bases 2, 8, 16• Technique: Divide the number using the appropriate base,

then repeatedly divide the resulting quotients by the same base until it becomes zero. The answer is the combined remainders in reverse order accumulated from the divisions. This technique is called the remainder method.

• Convert 13310 to base 2.133 ÷ 2 = 66 r. 166 ÷ 2 = 33 r. 033 ÷ 2 = 16 r. 116 ÷ 2 = 8 r. 08 ÷ 2 = 4 r. 04 ÷ 2 = 2 r. 02 ÷ 2 = 1 r. 01 ÷ 2 = 0 r. 1

Answer: 100001012

24

Conversion from Base 10 to Bases 2, 8, 16• Technique: Divide the number using the appropriate

base, then repeatedly divide the resulting quotients by the same base until it becomes zero. The answer is the combined remainders in reverse order accumulated from the divisions. This technique is called the remainder method.

• Convert 786310 to base 8.7863 ÷ 8 = 982 r. 7982 ÷ 8 = 122 r. 6122 ÷ 8 = 15 r. 215 ÷ 8 = 1 r. 71 ÷ 8 = 0 r. 1

Answer: 172678

25

Conversion from Base 10 to Bases 2, 8, 16• Technique: Divide the number using the appropriate

base, then repeatedly divide the resulting quotients by the same base until it becomes zero. The answer is the combined remainders in reverse order accumulated from the divisions. This technique is called the remainder method.

• Convert 292610 to base 16.2926 ÷ 16 = 182 r. 14(E)182 ÷ 16 = 11 r. 611 ÷ 16 = 0 r. 11(B)

Answer: B6E16

26

Conversion from Base 8 to Base 2• Technique: Convert each octal digit to a set of three

binary digits.

• Convert 56418 to base 2.

5 6 4 1101 110 100 001

Answer: 1011101000012

27

Conversion from Base 2 to Base 8• Technique: Convert each set of three binary digits to an

octal digit starting from the right going to the left, adding leading zeroes if necessary.

• Convert 11110102 to base 8.

001 111 0101 7 2

Answer: 1728

28

Conversion from Base 16 to Base 2• Technique: Convert each hexadecimal digit to a set of

four binary digits.

• Convert A3CF16 to base 2.

A 3 C F1010 0011 1100 1111

Answer: 10100011110011112

29

Conversion from Base 2 to Base 16• Technique: Convert each set of four binary digits to a

hexadecimal digit starting from the right going to the left, adding leading zeroes if necessary.

• Convert 1010110102 to base 16.

0001 0101 10101 5 A

Answer: 15A16

30

Decimal to Binary Fraction

0.625 = 0.625 x 2 = 1.25 1 0.25 x 2 = 0.5 0 0.5 x 2 = 1.0 1

0.625 = 0.1012

Binary to Decimal Fraction

0.0112 = (0x2-1)+(1x2-2)+(1x2-3)= 0 + 1/4 + 1/8= 0.25 + 0.125

0.0112 = 0.375

CONVERSION OF FRACTIONS

31

BINARY ADDITION

0 + 0 = 00 + 1 = 11 + 0 = 11 + 1 = 0 plus a carry over of 11 + 1 + 1 = 1 plus a carry over of 1

1. 1 0 02 2. 1 0 1 02 3. 1 1 . 0 12

+ 1 12 + 1 1 02 + 1 0 1 . 1 12

1 1 12 1 0 0 0 02 1 0 0 1 . 0 02

32

BINARY SUBTRACTION

0 - 0 = 01 - 0 = 11 - 1 = 00 - 1 = 1 with a borrow of 1

1. 1 0 1 0 2. 1 0 0 0 1 1 - 1 0 0 - 1 0 1 0 1 1 0 1 0 0 0 1

3. 1 0 0 0 . 1 1 4. 1 0 1 - 1 1 . 0 1 - 1 1 1 1 0 1 . 1 0 - 0 1 0

33

BINARY SUBTRACTION BY COMPLEMENTING

• The computer performs subtraction by a series of negative additions.• Subtraction is accomplished by adding the complement of the number to be subtracted.• The one’s complement of a binary number is simply the difference between 1 and each of the digits of the number.

for example, the complement of 102 is 012 because:

1 12

- 1 02

0 12

34

BINARY SUBTRACTION BY COMPLEMENTING

1. 1 1 0 0 1 12 1 1 0 0 1 1 - 1 1 1 0 12 + 0 0 0 1 0 (complement) 1 0 1 1 02 1 1 0 1 0 1 (binary sum)

+ 1 (end-around carry) 1 0 1 1 02 (answer)

To subtract by complementing in the binary system, add the one’s complement plus 1, and ignore the initial 1.

Using one’s complement:

35

BINARY SUBTRACTION BY COMPLEMENTING

2. 1 1 0 0 . 0 12 1 1 0 0 . 0 1 - 1 0 1 0 . 1 02 + 0 1 0 1 . 1 0 (complement) 0 0 0 1 . 112 1 0 0 0 1 . 1 0 (binary sum)

+ 1 (end-around carry) 1 . 1 12 (answer)

Using one’s complement:

3. 1 1 0 0 02 1 1 0 0 0 - 1 1 1 0 12 + 0 0 0 1 0 (complement) - 0 0 1 0 1 2 1 1 0 1 0 (binary sum)

The answer is determined by taking the complement of the binary sum and prefixing a negative sign, therefore the answer would be:

- 0 0 1 0 12 (answer)

36

BINARY SUBTRACTION BY COMPLEMENTING

4. - 1 1 0 1 11111 11111 1 0 0 1 0 - 0 1 1 0 - 1101 - 0110 +1 1 0 0 1 - 1 0 0 1 1 10010 11001 1 0 1 0 1 1

+ 10 1 1 0 0

- 1 1 1 1 1 - 1 0 0 1 1

Using one’s complement:

37

BINARY SUBTRACTION BY COMPLEMENTING

Using two’s complement:

1. 110011 - 11101 10110

111111- 11101 000010+ 1 000011+ 110011 110110

2. 1100.11 - 1010.10 1.11

1111.11- 1010.10 0101.01+ 1 0101.10+1100.0110001.11

3. 11000 - 11101 - 101

11111- 11101 00010+ 1 00011+11000 11011

-00100+ - 1 -00101

38

BINARY SUBTRACTION BY COMPLEMENTING

Using two’s complement:

4. - 1 1 0 1 11111 11111 1 0 0 1 1 - 0 1 1 0 - 1101 - 0110 +1 1 0 1 0 - 1 0 0 1 1 10010 11001 1 0 1 1 0 1

+ 1 + 1 - 1 1 1 1 110011 11010 - 1 0 0 1 0

- 1

- 1 0 0 1 1

39

BINARY MULTIPLICATION

0 x 0 = 01 x 0 = 00 x 1 = 01 x 1 = 1

1 1 1 x 1 0 1 1 1 1 + 0 0 0 1 1 1 1 0 0 0 0 12

2. 1 1 . 0 0 x 1 0 . 1 0 0 0 0 0

1 1 0 0 0 0 0 0

1 1 0 0 1 1 1 . 1 0 0 02

1.

40

BINARY DIVISION

0 / 1 = 01 / 1 = 1

1. 11002 / 1002 = 112

because, 112 1100 100 1100 - 100 (1st subtraction) -100 1000 100 - 100 (2nd subtraction) -100 100 000 - 100 (3rd subtraction) 000 (remainder)the solution shows that there are 3 subtractions made, and has an equivalent of 112.

Exercises:

41

Convert the following:

Solve the following :

13)10110102 + 1101012 17) 12348 + 5678

14)10110102 - 1101012 18) 1358 - 788 15)11012 * 1012 19) 156816 + AA116

16)111002 / 1012 20) 9E216 - 1AA16

Decimal Binary Octal Hexadecimal1025 (1) (2) (3)

(4) 1101001 (5) (6)

(7) (8) 2008 (9)

(10) (11) (12) ABA

top related