Vous êtes sur la page 1sur 33

CHAPTER 2: Number Systems

The Architecture of Computer Hardware and Systems Software:


An Information Technology Approach 3rd Edition, Irv Englander John Wiley and Sons 2003
Linda Senne, Bentley College Wilson Wong, Bentley College

Why Binary?
Early computer design was decimal
Mark I and ENIAC

John von Neumann proposed binary data processing (1945)


Simplified computer design Used for both instructions and data

Natural relationship between on/off switches and calculation using Boolean logic
Chapter 2 Number Systems

On True Yes 1

Off False No 0
2-2

Counting and Arithmetic


Decimal or base 10 number system
Origin: counting on the fingers Digit from the Latin word digitus meaning finger

Base: the number of different digits including zero in the number system
Example: Base 10 has 10 digits, 0 through 9

Binary or base 2 Bit (binary digit): 2 digits, 0 and 1 Octal or base 8: 8 digits, 0 through 7 Hexadecimal or base 16: 16 digits, 0 through F
Examples: 1010 = A16; 1110 = B16
2-3

Chapter 2 Number Systems

Numbers: Physical Representation


Different numerals, same number of oranges
Cave dweller: IIIII Roman: V Arabic: 5

Different bases, same number of oranges


510 1012 123
Chapter 2 Number Systems 2-4

Number System
Roman: position independent Modern: based on positional notation (place value)
Decimal system: system of positional notation based on powers of 10. Binary system: system of positional notation based powers of 2 Octal system: system of positional notation based on powers of 8 Hexadecimal system: system of positional notation based powers of 16
Chapter 2 Number Systems 2-5

Positional Notation: Base 10


43 = 4 x 101 + 3 x 100
10s place 1s place

Place Value Evaluate

101 10 4 x 10

100 1 3 x1

Sum

40

Chapter 2 Number Systems

2-6

Positional Notation: Base 10


527 = 5 x 102 + 2 x 101 + 7 x 100
100s place 10s place 1s place

Place Value Evaluate Sum

102 100 5 x 100 500

101 10 2 x 10 20

100 1 7 x1 7

Chapter 2 Number Systems

2-7

Positional Notation: Octal


6248 = 40410
64s place 8s place 1s place

Place Value Evaluate

82 64 6 x 64

81 8 2x8

80 1 4x1

Sum for Base 10

384

16

Chapter 2 Number Systems

2-8

Positional Notation: Hexadecimal


6,70416 = 26,37210
4,096s place 256s place 16s place 1s place

Place Value Evaluate

163 4,096 6x 4,096

162 256 7 x 256

161 16 0 x 16

160 1 4x1

Sum for Base 10

24,576

1,792

Chapter 2 Number Systems

2-9

Positional Notation: Binary


1101 01102 = 21410
Place Value Evaluate Sum for Base 10 27 128 26 64 25 32 24 16 1 x16 16 23 8 0x8 0 22 4 1x4 4 21 2 1x2 2 20 1 0x1 0

1 x 128 1 x 64 0 x 32 128 64 0

Chapter 2 Number Systems

2-10

Estimating Magnitude: Binary


1101 01102 = 21410 1101 01102 > 19210 (128 + 64 + additional bits to the right)
Place Value Evaluate Sum for Base 10 27 128 26 64 25 32 0 x 32 0 24 16 1 x16 16 23 8 0x8 0 22 4 1x4 4 21 2 1x2 2 20 1 0x1 0

1 x 128 1 x 64 128 64

Chapter 2 Number Systems

2-11

Range of Possible Numbers


R = BK where
R = range B = base K = number of digits

Example #1: Base 10, 2 digits


R = 102 = 100 different numbers (099)

Example #2: Base 2, 16 digits


R = 216 = 65,536 or 64K 16-bit PC can store 65,536 different number values
Chapter 2 Number Systems 2-12

Decimal Range for Bit Widths


Bits Digits Range

1
4 8

0+
1+ 2+

2 (0 and 1)
16 (0 to 15) 256

10
16 20 32 64 128
Chapter 2 Number Systems

3
4+ 6 9+ 19+ 38+

1,024 (1K)
65,536 (64K) 1,048,576 (1M) 4,294,967,296 (4G) Approx. 1.6 x 1019 Approx. 2.6 x 1038
2-13

Base or Radix
Base:
The number of different symbols required to represent any given number

The larger the base, the more numerals are required


Base 10: Base 2: Base 8: Base 16: 0,1, 2,3,4,5,6,7,8,9 0,1 0,1,2, 3,4,5,6,7 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

Chapter 2 Number Systems

2-14

Number of Symbols vs. Number of Digits


For a given number, the larger the base
the more symbols required but the fewer digits needed

Example #1:
6516 10110 1458 110 01012 1 0001 11002

Example #2:
11C16 28410 4348

Chapter 2 Number Systems

2-15

Counting in Base 2
Binary Number 0 1 10 11 100 101 110 111 1000 1001 1010 1 x 23 1 x 23 1 x 23 1 x 21 1 x 20 1 x 22 1 x 22 1 x 22 1 x 22 1 x 21 1 x 21 1 x 20 1 x 20 1 x 21 1 x 21 Equivalent 8s (23) 4s (22) 2s (21) 1s (20) 0 x 20 1 x 20 0 x 20 1 x 20 Decimal Number 0 1 2 3 4 5 6 7 8 9 10
2-16

Chapter 2 Number Systems

Addition
Base Decimal Problem 6 +3 6 +1 6 +9 1 +0 Largest Single Digit 9

Octal Hexadecimal Binary

7 F 1

Chapter 2 Number Systems

2-17

Binary Arithmetic
1 1 1 1 1

1 + 1 0

1 0

0 1 0

1 0 0

1 1 0

0 1 1

1 0 1

Chapter 2 Number Systems

2-18

Binary Arithmetic
Addition Multiplication

+
0 1

0
0 1 0 0 1 0 0

1
1 10 1 0 1
2-19

Chapter 2 Number Systems

Binary Arithmetic: Boolean Logic


Boolean logic without performing arithmetic
EXCLUSIVE-OR

Output is 1 only if either input, but not both inputs, is a 1 Output is 1 if and only both inputs are a 1

AND (carry bit)

+ 1

0 1 0

1 0 0

1 1 0

0 1 1

1 0 1
2-20

Chapter 2 Number Systems

Binary Multiplication
Boolean logic without performing arithmetic
Shift

Shifting a number in any base left one digit multiplies its value by the base Shifting a number in any base right one digit divides its value by the base Examples:

1010 shift left = 10010 102 shift left = 1002

1010 shift right = 110 102 shift right = 12


2-21

Chapter 2 Number Systems

Binary Multiplication
1 1 1 1 1 0 0 0 0 1 1 1 1s place
2s place

1
1 0

1
0

0 1
0 0 0

4s place (bits shifted to line up with 4s place of multiplier)

1 Result (AND)

Chapter 2 Number Systems

2-22

Binary Multiplication
1 1 0 1 1 0 1

x
1 1 1 1 1 0 1 0 0 0 1 1 0 0 1 0 0 0

1
0 1 1 1

0
1 1

0 1
1 0 0 1

1
1

0
2s place (bits shifted to line up with 2s place of multiplier) 4s place 32s place

1 1

0 Result (AND)

Note the 0 at the end, since the 1s place is not brought down.

Note: multiple carries are possible.

Chapter 2 Number Systems

2-23

Converting from Base 10


Powers Table
Power Base 2 8 256 7 128 6 64 5 32 32,768 4 16 4,096 3 8 512 2 4 64 256 1 2 8 16 0 1 1 1

8
16

65,536 4,096

Chapter 2 Number Systems

2-24

From Base 10 to Base 2


4210 = 1010102
Power Base 2 6 64 5 32 1 Integer Remainder 42/32 =1 10 4 16 0 10/16 =0 10 3 8 1 10/8 =1 2 2 4 0 2/4 =0 2 1 2 1 2/2 =1 0 0 1 0 0/1 =0 0

Chapter 2 Number Systems

2-25

From Base 10 to Base 2


Base 10 42
Quotient Remainder

2 ) 42 ( 0 Least significant bit

2 ) 21 ( 1 2 ) 10 ( 0
2) 2) 2) Base 2
Chapter 2 Number Systems

5 (1 2 (0 1 Most significant bit 101010


2-26

From Base 10 to Base 16


5,73510 = 166716
Power Base 4 3 2 1 0

16

65,536

4,096 1

256 6 1,639 / 256 =6

16 6 103 /16 =6

1 7 7

Integer Remainder

5,735 /4,096 =1

5,735 - 4,096 1,639 1,536 103 96 = 1,639 = 103 =7

Chapter 2 Number Systems

2-27

From Base 10 to Base 16


Base 10 5,735
Quotient 16 ) Remainder

5,735 ( 7 Least significant bit 358 ( 6 22 ( 6 1 ( 1 Most significant bit 0 1667


2-28

16 ) 16 ) 16 ) 16 ) Base 16
Chapter 2 Number Systems

From Base 10 to Base 16


Base 10 8,039
Quotient 16 ) Remainder

8,039 ( 7 Least significant bit 502 ( 6 31 ( 15 1 ( 1 Most significant bit 0 1F67


2-29

16 ) 16 ) 16 ) 16 ) Base 16
Chapter 2 Number Systems

From Base 8 to Base 10


72638 = 3,76310
Power 83 512 x7
Sum for Base 10

82 64 x2 128

81 8 x6 48

80 1 x3 3

3,584

Chapter 2 Number Systems

2-30

From Base 8 to Base 10


72638 = 3,76310 7 x8 56 + 2 =

58 x8 464 + 6 =

470 x8 3760 + 3 = 3,763


2-31

Chapter 2 Number Systems

From Base 16 to Base 2


The nibble approach
Hex easier to read and write than binary

Base 16

F 1111

6 0110

7 0111

Base 2 0001
Why hexadecimal?

Modern computer operating systems and networks present variety of troubleshooting data in hex format
2-32

Chapter 2 Number Systems

Copyright 2003 John Wiley & Sons


All rights reserved. Reproduction or translation of this work beyond that permitted in Section 117 of the 1976 United States Copyright Act without express permission of the copyright owner is unlawful. Request for further information should be addressed to the permissions Department, John Wiley & Songs, Inc. The purchaser may make back-up copies for his/her own use only and not for distribution or resale. The Publisher assumes no responsibility for errors, omissions, or damages caused by the use of these programs or from the use of the information contained herein.

Chapter 2 Number Systems

2-33

Vous aimerez peut-être aussi