文档详情

计算机导论第二章讲稿

实名认证
店铺
PDF
513.83KB
约51页
文档ID:46934083
计算机导论第二章讲稿_第1页
1/51

1 1Chapter 2 Number SystemsFoundations of Computer Science Second Edition BEHROUZ FOROUZAN FIROUZ MOSHARRAF2CSIM@PU2Outlines?Introduction?Positional Number Systems–Base 10, 2, 8, 16.?Nonpositional Number Systems–Roman Numerals3CSIM@PU3ObjectivesAfter studying this chapter, the student should understand:?The concept of number systems.?Non-positional and positional number systems.?Decimal, Binary, Hexadecimal and Octal system. ?Convert a number among binary, octal, hexadecimal, and decimal systems.?Find the number of digits needed in each system to represent a particular value.4 41-1 Introduction5CSIM@PU5The Definition of Number System•A number can be represented using distinct symbols and differently in different systems. •For example, •The two numbers (2A)16and (52)8 both refer to the same quantity, (42)10, but their representations are different •Two groups •positional and non-positional systems6 61-2 Position Number Systems7CSIM@PU7Overview?In a positional number system, a number represented as:has the value of:in which S is the set of symbols, b is the base (or radix).The Base includes Base10(Decimal), Base2(Binary), Base 16(Hexadecimal), or Base8(octal)。

8The decimal system (base 10)?The word decimal is derived from the Latin root decem (ten). –base b = 10, and –ten symbols: S = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}?The symbols in this system are often referred to as decimal digits or just digits.–Integer examples–Real examples9Base 10 – Integers (1)Figure 2.1 Place values for an integer in the decimal system10Base 10 – Integers (2)?Example 2.1 shows the place values for the integer +224 in the decimal system?Example 2.2 shows the place values for the decimal number −7508()Values11Base 10 – Reals?A real – a number with a fractional part?Example 2.3 shows the place values for the real number +24.13.12The binary system (base 2)?The word binary is derived from the Latin root bini (or two by two). –base b = 2, and –two symbols, S = {0, 1}?The symbols in this system are often referred to as binary digits or bits (binary digit).–Integer examples–Real examples13Base 2 – Integers (1)?We can represent an Integer as:Figure 2.2 Place values for an integer in the binary system14Base 2 – Integers (2)?Example 2.4 shows that the number (11001)2 in binary is the same as 25 in decimal. The subscript 2 shows that the base is 2.The equivalent decimal number is N = 16 + 8 + 0 + 0 + 1 = 25.The equivalent decimal number is N = 16 + 8 + 0 + 0 + 1 = 25.15Base 2 – Reals (1)?Example 2.5 shows that the number (101.11)2 in binary is equal to the number 5.75 in decimal.The equivalent decimal number is R = 4+0+1+0.5+0.25 = 5.75.The equivalent decimal number is R = 4+0+1+0.5+0.25 = 5.75.16The hexadecimal system (base 16)?The word hexadecimal is derived from the Greek root hex (six) and the Latin root decem (ten). –base b = 16, and –sixteen symbols,?Symbol A, B, C, D, E, F are equivalent to 10, 11, 12, 13, 14, and 15 respectively. ?The symbols in this system are often referred to as hexadecimal digits.S = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}17Base 16 – Integers (1)?We can represent an Integer as:Figure 2.3 Place values for an integer in the hexadecimal system18Base 16 – Integers (2)?Example 2.6 shows that the number (2AE)16 in hexadecimalThe equivalent decimal number is N = 512 + 160 + 14 = 686.The equivalent decimal number is N = 512 + 160 + 14 = 686.19The octal system (base 8)?The word octal is derived from the Latin root octo (eight). –base b = 8, and –Eight symbols, S = {0, 1, 2, 3, 4, 5, 6, 7}?Place values for an integer in the octal system20Base 8 – Integers (1)?We can represent an Integer as:Figure 2.4 Place values for an integer in the octal system21Base 8 – Integers (2)?Example 2.7 shows that the number (1256)8 in octal is the same as 686 in decimal.The decimal number is N = 512 + 128 + 40 + 6 = 686.22Summary of the Base 10/2/8/16 positional systems (1)23Summary (2)The number 0 to 15 is represented in different systems24Conversion?The decimal system is more familiar than the other systems?To convert a number in one system to the equivalent number in another system–Any base – Decimal–Binary – Hexadecimal–Binary – Octal–Octal – Hexadecimal25Any base to decimal conversion (1)?Converting other bases to decimal (Fig. 2.5)26Any base to decimal conversion (2)?Example 2.8 shows how to convert the binary number (110.11)2to decimal: (110.11)2= 6.75.27Any base to decimal conversion (3)?Example 2.9 shows how to convert the hexadecimal number (1A.23)16to decimal.The result in the decimal notation is not exact, because 3 × 16−2= 0.01171875. We have rounded this value to three digits (0.012). 28Any base to decimal conversion (4)?Example 2.10 shows how to convert (23.17)8 to decimal.This means that (23.17)8 ≈ 19.234 in decimal. Again, we have rounded up 7 × 8−2= 0.109375.29Decimal to any base conversion ?Two procedures for converting a decimal number to its equivalent in any base.–Converting the in。

下载提示
相似文档
正为您匹配相似的精品文档