Presentation is loading. Please wait.

Presentation is loading. Please wait.

CHAPTER 2 NUMBER SYSTEMS, OPERATIONS, AND CODES 数制系统、运算和编码 主讲教师:谷雷.

Similar presentations


Presentation on theme: "CHAPTER 2 NUMBER SYSTEMS, OPERATIONS, AND CODES 数制系统、运算和编码 主讲教师:谷雷."— Presentation transcript:

1 CHAPTER 2 NUMBER SYSTEMS, OPERATIONS, AND CODES 数制系统、运算和编码 主讲教师:谷雷

2 2-1 DECIMAL NUMBERS 十进制数

3 Introductory Paragraph  You are familiar with the decimal number system because you use decimal numbers every day. Although decimal numbers are commonplace, their weighted structure is often not understood. In this section, the structure of decimal numbers is reviewed. Their review will help you more easily understand the structure of the binary number system, which is important in computers and digital electronics.

4 Decimal Review  Numbers consist of a bunch of digits, each with a weight. These weights are all powers of the base, which is 10. We can rewrite this: To find the decimal value of a number, multiply each digit by its weight and sum the products.

5 Nothing Special about 10!  Decimal system (and the idea of “0”) was invented in India around 100-500A.D.  Why did they use 10? Anything special about it?  Not really.  Probably the fact that we have 10 fingers influenced this.  Will a base other than 10 work?  Sure. What about base 2?

6 2-2 BINARY NUMBERS 二进制数

7 Introductory Paragraph  The binary number system is simply another way to represent quantities. The binary system is less complicated than the decimal system because it has only two digits. It may seem more difficult at first because it is unfamiliar to you. The decimal system with its ten digits is a base-ten system; The binary system with its two digits is a base- two system. The weights in a binary number are based on powers of two.

8 Counting in Binary  A binary count of 0 through 15 is shown below. As you will see, 4 bits are required to count from 0 to 15.

9 The Weighting Structure of Binary Numbers  A binary number is a weighted number (加权数). The right-most bit is the LSB (最低有效位) in a binary whole number and has a weight of 1(2 0 ). The weights increase from right to left by a power of two for each bit. The left-most bit is the MSB (最高有效位).  Fractional numbers (小数) can also be represented in binary by placing bits to the right of the binary point. The left-most bit is the MSB in a binary fractional number and has a weight of 2 -1 =0.5. The fractional weights decreases from left to right by a negative power of two for each bit.  The weight structure of a binary number is

10 2-2-1 Binary-to Decimal Conversion  The decimal value of any binary number can be found by adding the weights of all bits that are 1 and discarding the weights of all bits that are 0.

11 2-2-2 DECIMAL-TO-BINARY CONVERSION Repeated Division-by-2 Method  A systematic method of converting whole numbers from decimal to binary is the repeated division- by-2 process.

12 Repeated Multiplication-by-2 Method  A systematic method of converting fractional numbers from decimal to binary is the repeated multiplication-by-2 process.

13 2-7 HEXADECIMAL NUMBERS (十六进制数)

14 Why Hexadecimal?  As you are probably aware, long binary numbers are difficult to read and write because it is easy to drop or transpose a bit. Since computers and microprocessors understand only 1s and 0s, it is necessary to use these digits when you program in machine language.  The hexadecimal number system has 16 digits and is used primarily as a compact way of displaying or writing binary numbers because it is very easy to convert between binary and hexadecimal.  10 numeric digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) and 6 alphabetic characters (A, B, C, D, E, F) make up the hexadecimal number system.

15 Relationship between hexadecimal and binary  Each hexadecimal digit represents a 4-bit binary number.

16 Binary-to-Hexadecimal Conversion  Very straightforward! Simply break the binary number into 4-bit groups, starting at the right- most bit and replace each 4-bit group with the equivalent hexadecimal symbol.  [Example 2-24] Convert the following binary numbers to hexadecimal: (a) 1100101001010111 (b) 111111000101101001

17 Hexadecimal-to-Binary Conversion  Very straightforward! Simply replace each hexadecimal symbol with the equivalent 4-bit group.  [Example 2-25] Determine the binary numbers for the following hexadecimal numbers: (a) (10A4) 16 (b) (CF8E) 16

18 Hexadecimal-to-Decimal Conversion  Multiply the decimal value of each hexadecimal digit by its weight and then take the sum of these products.  [Example 2-27] Convert the following hexadecimal numbers to decimal: (a) (E5) 16 (a) (E5) 16 =14×16 1 +5 ×16 0 =(304) 10

19 Decimal-to-Hexadecimal Conversion  Repeated division of a decimal number by 16 will produce the equivalent hexadecimal number.  [Example 2-28] Convert the decimal number 650 to hexadecimal by repeated division by 16.

20 2-8 OCTAL NUMBERS (八进制数)

21  Like the hexadecimal system, the octal system provides a convenient way to express binary numbers and codes. However, it is used less frequently than hexadecimal in conjunction with computers and microprocessors to express binary quantities.  The octal number system is composed of eight digits, which are 0, 1, 2, 3, 4, 5, 6, 7

22 Octal-to-Decimal Conversion  The evaluation of an octal number in terms of its decimal equivalent is accomplished by multiplying each digit by its weight and summing the products, as illustrated here for(2374) 8. Weight: 8 3 8 2 8 1 8 0 Octal number: 2 3 7 4 (2374) 8 = (2× 8 3 ) + (3× 8 2 ) + (7× 8 1 ) + (4× 8 0 ) = (2×512) + (3×64) + (7×8) + (4×1) = 1024 + 192 + 56 + 4 = (1276) 10

23 Decimal-to-Octal Conversion  Repeated division of a decimal number by 8 will produce the equivalent Octal number.  [Example] Convert the decimal number 359 to Octal by repeated division by 8. (547) 8

24  Because each octal digit can be represented by a 3- bit binary number, it is very easy to convert from octal to binary. Each octal digit is represented by three bits as shown in tab 2-4. TABLE 2-4 Octal/binary conversion.  [Example 2-28] Conversion each of the following octal numbers to binary : (a) 13 8 (b) 25 8 (c) 140 8 Octal-to-Binary Conversion Octal Digit01234567 Binary000001010011100101110111

25 Binary-to-Octal Conversion  Break the binary number into 3-bit groups, starting at the right-most bit and replace each 3-bit group with the equivalent Octal numbers.  [Example 2-29] Convert the following binary numbers to Octal: (a) 110101 (b) 101111001

26 Summary of Conversion of Number Systems  1.R – to – Decimal Conversion Method : Multiply the decimal value of each R digit by its weight and then take the sum of these products. a.(1101.101) 2 b. (105.51) 8 c. (2AE.B5) 16 =1×2 3 +1×2 2 +0×2 1 +1×2 0 +1×2 -1 +0×2 -2 +1×2 -3 =(13.625) 10 = 1×8 2 +0×8 1 +5×8 0 +5×8 -1 +1×8 -2 =(69.640625) 10 = 2×16 2 +10×16 1 +14×16 0 +11×16 -1 +5×16 -2 =(686.70703) 10

27  2.Decimal – to – R Conversion Method : Decimal-Binary-R 1.repeated division-by-2 2.repeated multiplication-by-2 (25.7) 10 =(11001.1011) 2 =(31.54) 8 =(19.B) 16

28  3.Binary Octal Hexadecimal (1110.0111) 2 =(16.34) 8 =(E.7) 16 (6.44) 8 =(0110.1001) 2 =(6.9) 16 (3D.BE) 16 =(00111101.10111110) 2 =(75.574) 8


Download ppt "CHAPTER 2 NUMBER SYSTEMS, OPERATIONS, AND CODES 数制系统、运算和编码 主讲教师:谷雷."

Similar presentations


Ads by Google