Due 24 August (Friday, 11:59 p.m. EDT) Use Module 1 and Book Chapters 1 – 3 (module at bottom/chapters attached) SHOW ALL WORK OR NO CREDIT 1. (10 Points) Virtualization is a concept that has taken on major importance in the early twenty-first century. Explain what is meant by virtualization. 2. (10 Points) What is a protocol? What is a standard? Do all protocols have to be standards? Explain. 3. (10 Points) Protocols and standards are important features of networks. Why is this so? 4. (10 Points) What are the most important ideas, keywords, and phrases that are stated in the definition of a system? 5. (10 Points) Convert the following hexadecimal numbers to decimal: . a) 4E b) 3D7 c) 3D70 6. (10 Points) Add the following binary numbers: a) 101101101 + 10011011 b) 110111111 + 110111111 c) 1101 1010 111 + 101 Page 1 of 20 7. (10 Points) Multiply the following binary numbers together: a) 1101 × 101 b) 11011 × 1011 8. (10 Points) Perform the following binary divisions: a) 1010001001 ÷ 110 b) 11000000000 ÷ 1011 9. (10 Points) Using the division method, convert the following decimal numbers to binary: a.) 4098 b) 71269 10. (10 Points) Convert the following binary numbers directly to hexadecimal: . a) 101101110111010 b) 1111111111110001 Page 2 of 20 Module 1 1. Computer Systems We start this section with a short discussion of why you should be studying software, hardware, and data concepts. You may ask: Why should we study the concepts of computer data, computer hardware, and computer software? What are the components of a digital computer system and how do they work together? How are information systems developed for computers? 1.1 Why Study Computer Concepts? The answer to this question is that the understanding of these concepts is at the very foundation of being both competent and successful in your segment of the field of computers. Computer users will: be aware of system capabilities, strategies, and limitations better understand the commands that they use be able to make informed decisions about computer equipment and applications improve their ability to communicate with other computer professionals Computer programmers will: be able to write better programs by using characteristics of the computer to make the programs more efficient understand why compiled languages such as COBOL, C++, or Java run faster than interpreted languages such as BASIC System analysts will be able to: read and understand technical specifications determine the correct computer strategy for a particular application assist management in determining computer strategy determine when to replace older equipment System administrators or managers will: maximize the efficiency of their computer systems know when additional resources are required for those systems understand how to specify and configure operating system parameters know how to set up file systems be able to manage system and user PC upgrades Each of these computer professionals will understand how the computer hardware and software work together with programs and data in a computer system. Page 3 of 20 1.2 Computer System Components Four components that are required for the implementation of a computer system are: computer hardware computer software data communications We will study all four of these components. The hardware component includes: the central processing unit (CPU) o the arithmetic/logic unit (ALU) o the control unit o registers memory, also known as primary storage the system bus, or interface unit, used for internal communications to connect the other hardware components together input/output (I/O) modules used for external communications The software component includes: application software systems software The data component includes: binary/alphanumeric/image data binary representations of the above The communications component includes: connections between computers connections between computer networks 1.3 Information System Development Information systems are developed using formalized methodologies. The traditional methodology, known as the Systems Development Life Cycle (SDLC) and also as the Waterfall methodology, has a series of specific steps that are to be followed. Each step must be completed before the next one is started. The name Waterfall is applied because the likelihood of going back to a previous step is similar to the likelihood of swimming upstream in a waterfall. Typical implementations of a SDLC have most, if not all, of the following steps: systems survey, systems engineering, or preliminary investigation analysis, system analysis, requirements analysis, or needs analysis design, or system design system implementation, which may be further broken down to: o construction Page 4 of 20 o implementation o installation system evaluation or post-implementation review maintenance At the end of the process, it may be necessary to go back to the beginning to resolve any problems with the information system. 1.4 The Flow of the Course We will start the course in module 1 by looking at the way that we represent and use data. We will be studying the hardware components in modules 2 through 4. In module 2, we will be looking at the details of digital logic and how this logic is put together into larger components that are used in the computer. In module 3, we will study the CPU, memory, and the interface unit. In module 4, we will study the input and output modules and then put the pieces of the computer together. Module 5 will be an introduction to communications between and among computers and the Internet. In module 6, we will look at the components of the system software. These components are collectively known as the operating system and its supporting utility programs. We will also look at programming tools and system administration. 2. Number Systems There are three numbering systems that we need to be aware of: decimal, binary, and hexadecimal. We are most familiar with the decimal number system because that is what we use in our day-to-day lives. Base 10 goes back to the days when the counting system was based on the number of fingers on a person's hand. Computers, on the other hand, use bits and the binary number system because their circuitry is based on two discrete states. You can think of two discrete states as 1/0, on/off, true/false, or high voltage/low voltage. It is in terms of voltage that the binary number system is implemented in a digital computer. We study the binary number system to help us understand how computers work. We can use the decimal number system—the one we are used to working with—to help us see why the binary number system works. The hexadecimal number system is not implemented in computer hardware or normally used as input/output data that is seen by the end user. Hexadecimal is often used by programmers and computer technicians as a shorthand way of representing strings of bits. Hexadecimal numbers are not only easier to read, but take up less space because one hexadecimal character is equal to a four-bit binary sequence. For example, E6 is the hexadecimal equivalent of binary 11100110. Times when programmers might prefer to write binary numbers in hexadecimal are: when they must do a data dump in order to trace problems after programs abort due to "fatal errors" when they need to read data from test equipment to analyze computer and communication circuits Page 5 of 20 2.1 Decimal and Binary First, let's discuss the relationship between decimal and binary values. Table 1-1 is important, showing decimal and binary values for selected values of 2. It tells us that every set of 2 raised to the 10th power is approximately equal to 10 raised to the 3 rd power (210 = 1024; 103 = 1000). Computer design takes advantage of these numbers, as we will see throughout this module and this entire course. Because this is a large table, you may want to print it out so that you can easily refer to it when needed. Table 1-1 Powers of 2 Decimal 2x .125 2 -3 .25 2 -2 .5 2 -1 0 1 2 2 21 4 22 8 23 16 24 5 32 2 64 26 128 27 256 28 512 29 10 2 1024 = 1 K (kilo) or approximately 1 thousand Binary .001 .01 .1 1 10 100 1000 10000 100000 1000000 10000000 100000000 1000000000 10000000000 . . .which is also (10000000000) 1 2 20 10 6 = 1 M (meg) 100000000000000000000 or approximately 1 million . . .which is also (10000000000) 2 2 30 10 9 = 1 G (gig) 1000000000000000000000000000000 or approximately 1 billion . . .which is also (10000000000) 3 2 40 1012 = 1 T (tera) 10000000000000000000000000000000000000000 or approximately 1 trillion . . .which is also (10000000000) 4 2 50 1015 =1 P (peta) 100000000000000000000000000000000000000000000000000 or approximately 1 quadrillion . . .which is also (10000000000) 5 Computer professionals often use the terms kilobyte, megabyte, and gigabyte to represent one thousand, one million, or one billion bytes. They are starting to use the term terabyte to represent 1 trillion bytes, and in the not-too-distant future they will also be using petabyte to represent 1 quadrillion bytes. You should recognize that these numbers are represented by the powers of 2 and 10, as shown in the table above. The concept of powers of 2 is important because of its use in addressing, which is the way that the computer finds the location of a word or piece of data in memory. As the size of memory increases, the number of bits required to uniquely address all locations increases. A Page 6 of 20 kilobyte of memory requires 10 bits to create a unique address, while a megabyte memory requires a 20-bit address, and a gigabyte of memory requires a 30-bit address. An example of addressing in the decimal world is the use of your house address to determine where to deliver your mail. Suppose you live at 4132 A Street. There might be 10,000 houses numbered from 0 to 9999 on the same street. Mail to be delivered to you comes to the house (address) numbered 4132. Therefore, we need only four decimal numbers to uniquely assign 104, or 10,000 addresses. Figure 1-1 Addressing in the Real World In the binary world, 10 bits provide 210, or 1024 unique addresses, and 30 bits provide 230, or approximately one billion unique addresses. Another fact to remember from your algebra courses is that we can apply the Product Rule to more easily handle the powers of 2 that we will see in this course. This rule states that na+b = na x nb Using numbers in the binary world: 6553610 = 64K = 210 x 26 = 216 We used Table 1.1 above to find that 1K was 210 and that 64 was 26. Then we added the exponents 10 and 6 together to get 216. This technique will be used throughout the course. Can you use it to determine how many bits are required to address the memory of your computer? We will talk about addressing throughout the course, with a strong emphasis on it when we discuss memory in module 2. To demonstrate an interesting pattern in the formation of binary numbers, we can use Table 1-2 below. Note the pattern of 0s and 1s for the first four columns, starting from the right: Table 1-2 Comparison of Binary and Decimal Decimal B i n a r y 3rd from right 2nd from right 1st from right Rightmost 0 0 0 0 0 1 0 0 0 1 Page 7 of 20 2 0 0 1 0 3 0 0 1 1 4 0 1 0 0 5 0 1 0 1 6 0 1 1 0 7 0 1 1 1 8 1 0 0 0 The rightmost column is alternating 0s and 1s. The next column is alternating sets of two 0s and two 1s. Now the next column is alternating sets of four 0s and four 1s. The four 0s are in rows 0-3 and the four 1s are in rows 4 through 7. As we could now predict, the fourth column will be alternating sets of eight 0s and eight 1s. Rows 0 through 7 were 0 and then row 8 is 1. We can easily use this knowledge to establish a table of binary numbers of any length by alternating 0s and 1s in the above format. If we are to use these number systems, it is important to be able to convert between number systems. Let's start with conversions between decimal (base 10) and binary (base 2) numbers. Converting Binary to Decimal Our number systems are positional systems with each digit having a multiplier based on its position in the number. See Examples 1-1 and 1-2 for examples in the decimal and binary number systems. Example 1-1 Positional Values in the Decimal Number System The value of the decimal number 98,765.43210 is equal to each digit multiplied by the positional value of that digit as shown on the next line 9 x 104 + 8 x 103 + 7 x 102 + 6 x 101 + 5 x 100 + 4 x 10-1 + 3 x 10-2 + 2 x 10-3 When multiplied out, we get the result shown on the two lines below: 90,000 + 8,000 + 700 + 60 + 5 + .4 + .03 + .002 = 98,765.43210 Example 1-2 Positional Values in the Binary Numbering System The decimal value of the binary number 1 1 0 0 1 0 . 0 1 2 is equal to each bit multiplied by the positional value of that bit as shown on the next line 1 x 25 + 1 x 2 4 + 0 x 23 + 0 x 22 + 1 x 21 + 0 x 2 0 + 0 x 2-1 + 1 x 2-2 When multiplied out, we get the decimal result on the line below 32 + 16 + 0 + 0 + 2 + 0 + 0 + .25 = 50.2510 Note that in the decimal system position values are multiplied by 10 for each digit that we move to the left and divided by 10 for each digit that we move to the right. This holds true even as we cross the decimal point. Page 8 of 20 Likewise, the binary system position values are multiplied by 2 for each bit that we move to the left and divided by 2 for each bit that we move to the right. And this holds true even as we cross the binary point. In converting from binary to decimal, it is helpful to use Table 1-1. To perform the conversion, one has to simply write down the bits, and then below each one bit in the binary number, write down the decimal equivalent. The answer is obtained by summing the decimal equivalents. You can use Example 1-3, an interactive binary-to-decimal calculator, to help you calculate the decimal equivalents of binary numbers. When you click on one of the buttons, the number below it will highlight and that value will be added to the total. After you use this link a few times, you will probably find it easier to do the calculations manually. Converting Decimal to Binary There are two methods for converting decimal to binary. The first method is divided into two parts: one for the integer part of the decimal number and one for the fractional part of the decimal number. See Examples 1-4 and 1-5 for the decimal to binary conversions of decimal 43 and decimal .8125 respectively. In Example 1-4, we start with the 43, the given number, and successively divide quotients by 2, until you get a quotient of 0. Read off the remainders in reverse order to get the binary equivalent. In Example 1-5, we start with the .8125, the given number, and successively multiply the resulting fractional part by 2. To get the binary equivalent, read the digits to the left of the decimal in order after the fractional part becomes 0. The second method is a quick-and-dirty method often used by those comfortable with the binary number system. See Example 1-6 for the decimal to binary conversion of decimal 43. Because computer professionals often use hexadecimal number systems, it is also important to be able to convert among all three number systems—binary, hexadecimal, and decimal. Therefore we next investigate hexadecimal numbers which are closely related to binary because 16 is an exact power of 2. 2.2 Hexadecimal The method for converting hexadecimal to decimal is similar to the way that we convert binary to decimal. See Example 1-7. Example 1-7 Converting a Hexadecimal Number to a Decimal Number (where B is the hexadecimal representation of 11 and D is the hexadecimal representation of 13) Likewise, converting from decimal to hexadecimal is similar to the way we convert from decimal to binary. See Example 1-8 for converting the decimal number 43.8125 to a hexadecimal number. It is also important to convert from hexadecimal to binary and from binary to hexadecimal. Looking at Table 1-3, we see that the relationship between binary and hexadecimal is a direct conversion where each four bits converts to one hexadecimal character. Page 9 of 20 Table 1-3 Relationship Between Binary and Hexadecimal Binary Hexadecimal 0000 0 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 1001 9 1010 A 1011 B 1100 C 1101 D 1110 E 1111 F Note that computing the decimal equivalent of the binary column gives us the first 10 values in the hexadecimal column. When converting from binary to hexadecimal, it is important to start at the binary point. Then count in groups of four bits, starting at the binary point and moving to both the right and left. These groups of four bits can be directly converted to hexadecimal using Table 1-3. You can use the interactive binary-to-hexadecimal and hexadecimal-to-binary calculators below to test your understanding of the conversion process. The binary-to-hexadecimal calculator in Example 1-9 starts with all zeros. You can input ones in any of the binary positions in the calculator and then click on "Calculate" to see the hexadecimal value. The hexadecimal-to-binary calculator of Example 1-10 starts with all zeros. You can input hexadecimal values from "0" to "F" in the hexadecimal positions in the calculator and then click on "Calculate" to see the binary value. 3. Representing Data 3.1 Complements An important concept in representing numerical data is complements. Complementing is one of three simple functions that computer hardware can perform. The other two functions are adding two binary numbers and making binary comparisons. The complement function changes all the values in a register to the opposite value. What this does is to allow the computer hardware to perform subtraction—and thus other functions such as division—without building more complex hardware. You need only one circuit to do several things, rather than a separate circuit for each function. This is possible because you can subtract B from A by complementing B and adding it to A. Page 10 of 20 The complement is a very powerful tool in computer hardware and software operations. We will learn how to create a complement and then, in the following section, how to use the complemented numbers in mathematical operations. There are two types of complements for the base 2 system: the 1's complement and 2's complement, respectively. Some older computers used 1's complement to perform mathematical operations. One such computer was the UNIVAC 1100 series. Today, however, PCs and most other computers use 2's complement for mathematical operations. We use the 1's complement simply as a step on the way to creating the 2's complement. The 2's complement is used to express a negative number. That is, we perform subtraction by adding the 2's complement representation of a negative number, rather than actually performing subtraction. The rule for taking the 1's complement is to change each 0 to a 1 and each 1 to a 0. The rule for taking the 2's complement is to mathematically add 1 to the 1's complement. See Example 1-11 for the 1's and 2's complement of a binary number. 3.2 Binary Representation Binary numbers in a digital computer can be represented as integer numbers, fixed-point numbers, or floating-point numbers. In any signed number system where there are positive and negative numbers, it is important to be able to identify which is which. In most systems we use "+" for positive and "–" for negative just before the absolute value of the number. Because a digital computer does not have a "+" or "–" sign—but only 0 and 1—a convention has been adopted for signed numbers. The leftmost bit, also known as the most significant bit (MSB), identifies the sign of the number. The MSB is: 0 when the sign is "+" (for positive numbers) 1 when the sign is "–" (for negative numbers) 3.2.1 Binary Integers The methods of representing integer numbers include sign-magnitude (also known as signand-magnitude or signed-magnitude), 1's complement, and 2's complement. The signmagnitude method uses the MSB for the sign bit and the remaining bits for the absolute value of the number. All positive integer numbers are represented in sign-magnitude. Negative integer numbers are expressed in the sign-magnitude, 1's complement, or 2's complement methods based on the system implemented in the specific computer being used. The three methods of expressing the decimal number –14 are shown in Table 1-4 below: Table 1-4 Three Ways of Representing –14 Method Representation Sign-magnitude 1000 1110 1's Complement 1111 0001 2's Complement 1111 0010 3.2.2 Binary Fixed-Point Numbers Integer numbers have no fractional components. They are always, by definition, whole numbers. When numbers do have a fractional component, they may be represented with a fixed number of positions to the right of the decimal (or binary point), or by use of scientific notation. Page 11 of 20 A good example of fixed-point representation in decimal is showing costs in dollars and cents. In this scheme, dollars are shown as positions to the left of the decimal point and cents are shown as the two positions to the right of the decimal point. In decimal, the two positions to the right of the decimal point are always shown—even if the cents portion is equal to zero. In binary, fixed-point representation is most often used in conjunction with Binary Coded Decimal (BCD) to represent dollars and cents. BCD is a system for representing numbers where single-decimal digits are represented by a set of four bits. As shown in Table 1-5 below, this system has the advantage of a direct correspondence to decimal numbers. Table 1-5 Binary Coded Decimal (BCD) Coding BCD Decimal BCD Decimal 0000 0 0101 5 0001 1 0110 6 0010 2 0111 7 0011 3 1000 8 0100 4 1001 9 There are two disadvantages to using this system: Four bits with 16 unique values are used to represent only 10 unique values (0 through 9). This is a waste of six possible combinations, and waste is always a problem when a computer system designer tries to cram as much capability and capacity into a computer system as is possible. The numbers used in this system cannot be operated on directly, but must be converted to another system in order to be used in the arithmetic and logic circuits. We will not work with BCD in this course, but you should be aware that it exists. 3.2.3 Binary Floating-point Numbers The major problem with integer and fixed-point representations is that they can represent only a limited range of numbers. For example, it would not be possible to represent a yearly salary of $40,000 using a 16-bit word (word is the basic unit of information) because the highest 16-bit number is +32K (32,768). Nor would it be possible to represent the trilliondollar national debt using a 32-bit word, because the largest negative 32-bit number is approximately –2 billion, even if we use integer dollars. Floating-point numbers, on the other hand, provide a way to represent a wide range of numbers by showing the most significant digits multiplied by the number system base (2 for binary or 10 for decimal) raised to an exponent. Floating-point numbers may be used to represent very large numbers (i.e., 100000000000000.), or very small numbers (i.e., .00000000000000000000000001), or negative numbers (i.e., –100.001). Let's look for a moment at decimal floating-point numbers, also known as scientific notation. We can represent 1234.5 as .12345 x 104 by moving the decimal point four places to the left and multiplying by 104. Page 12 of 20 Likewise, we may represent .000012345 as .12345 x 10–4 by moving the decimal point four places to the right and multiplying by 10–4. We can also represent –12.345 as –.12345 x 102. Note that for this base 10 system, we have a sign, a fractional value, and an exponent (power of 10 for base 10). In the last example, the sign is negative, the fraction part is .12345, and the exponent is 2. If we wanted to convert from scientific notation to a conventional decimal number, we would move the decimal point of the fractional part two places to the right (because the exponent is +2) and add a minus sign because the sign is negative. i.e., –.12345 x 102 = –12.345 Now let's move back to binary. Binary floating-point numbers for most modern CPUs (including Intel and SPARC) have floating-point instructions that conform to the IEEE Standard 754 format. This standard, established in 1985, facilitates the portability of programs from one computer to another and encourages the development of sophisticated numerical programs. The IEEE Standard 754 binary floating-point numbers have three components: sign bit (0 = positive; 1 = negative) exponent (a power of 2 because we are in base 2) significand (a normalized fractional component) and several formats, including a 32-bit format with an 8-bit exponent, and a 64-bit format with an 11-bit exponent. Each of these formats can handle, very large positive numbers with large positive exponents very small positive numbers with large negative exponents very large negative numbers very small negative numbers We will address only positive numbers with positive exponents in the 32-bit format. The format is shown below: Sign 1 bit Exponent 8 bits Significand 23 bits The 8-bit exponent follows a format called excess 127 where a binary exponent is converted to a 8-bit floating point exponent by adding binary 0111 1111 (decimal 127) to the binary value. Or a 8-bit floating point exponent is converted to a binary exponent by subtracting 0111 1111 (decimal 127). See Example 1-12 for three examples of a positive 8-bit exponent. We will not use negative numbers in this course. Example 1-12 Sample 8-bit Exponents for Binary Floating-Point Numbers a positive exponent of binary 1 (decimal 1) would have the 8-bit value of 1000 0000 which is computed by adding 1 to 0111 1111 a positive exponent of binary 101 (decimal 5) would have the 8bit value of 1000 0100 which is computed by adding 101 to Page 13 of 20 0111 1111 a positive exponent of binary 10100 (decimal 20) would have the 8-bit value of 1001 0011 which is computed by adding 1 0100 to 0111 1111 The significand represents a number that is equal to or greater than 1 and less than 2. It consists of an implied 1 bit an implied binary point 23 bits representing the fractional component of a number that has been normalized so that the most significant 1 is just to the left of the binary point Thus the most significant 1 is dropped from the floating-point number. (Its presence is implied.) By dropping the most significant 1 from the expression, one additional bit of information can be added. In the design of computers, designers are always looking for ways to add additional capability, and dropping that most significant 1 is one additional way to achieve that goal. It may not seem important, but, as an example, that extra bit makes a more accurate representation of pi. Note: The term "significand" is used to avoid confusion with the terms "normalized fractional part" or "mantissa." The use of the implied 1 is what differentiates significand from normalized fractional part or mantissa. Let's look at two examples. In Example 1-13, we convert a binary floating-point number in the IEEE Standard 754 format to a decimal number; then in Example 1-14, we convert a decimal number to a binary floating-point number in the IEEE Standard 754 format. 3.3 Character Representation We've discussed numbers, and how to represent them, but how do we represent characters? How are words represented in a word processing program? The answer is that we use certain codes for the translation of characters into bits. One of these codes is ASCII (pronounced AS-kee), which stands for American Standard Code for Information Interchange. ASCII uses seven bits to represent 128 characters (2 7 = 128) so there are no "wasted" combinations. Another popular bit translation code is IBM's EBCDIC (pronounced ebb-see-dick), which uses eight bits to represent 256 characters. It stands for Extended Binary Coded Decimal Interchange Code. Your textbook has a list of both codes. In addition to the letters of the alphabet, both ASCII and EBCDIC contain a series of control characters that are used in: formatting (such as BS and CR, representing backspace and carriage return) separating information (such as FS, GS, RS, and US, representing file separator, group separator, record separator, and unit separator) data communication protocols (such as DLE, SOH, and SYN, representing data link escape, start of header, and synchronous idle) We will study data communications later, in module 4. Page 14 of 20 4. Binary Integer Math 4.1 Adding Two One-bit Numbers The rules for adding two one-bit binary numbers are shown in Table 1-6: Table 1-6 Rules for Adding Two One-bit Binary Numbers The carry is done the same way that we do carries in decimal, i.e.,: When adding two multi-bit binary numbers, we need to include the carry from the previous bit. The rules are as shown in Table 1-7: Table 1-7 Rules for Adding Two Multi-bit Binary Numbers Carry-in 0 1st number 0 2nd number +0 result 00 including the carry bit 0 0 +1 01 0 1 +0 01 0 1 +1 10 1 0 +0 01 1 0 +1 10 1 1 +0 10 1 1 +1 11 4.2 Binary Addition and Subtraction in 2's Complement Math We need to establish several rules when performing binary addition: 1. There are a fixed number of bits with the most significant bit representing the sign bit (i.e., 0 = +, 1 = –). 2. Positive numbers are always represented in sign-magnitude format with the most significant bit (MSB) = 0. 3. Negative numbers are represented in 2's complement format with the MSB = 1. By using the 2's complement to represent negative numbers, computer addition and subtraction are both performed by adding two binary numbers. Let's look at all combinations of the numbers 10 and 4 using 8-bit binary number with 2's complement addition. The four possibilities are: 10 + 4; which could also be 10 – (– 4) Page 15 of 20 10 – 4; which could also be 10 + (– 4) –10 + 4; which could also be –10 – (– 4) –10 – 4; which could also be –10 + (– 4) Examples 1-15, 1-16, 1-18, and 1-19 demonstrate the addition for the four possibilities listed above. In these examples, the 8-bit numbers are shown as two groups of four bits separated by a space to make them simpler to read. The carries from the addition of the prior column are also shown. The binary answers inside the computer are shown in red. Example 1-15 Adding Two Positive 8-Bit Binary Numbers (10 + 4) +1010: 0000 10102 + 410: 0000 01002 +1410: 0000 11102 Click here to see the bit-by-bit progression of the addition. Example 1-16 Adding Positive and Negative Binary Numbers With a Positive Result (10 – 4) When we want to use a negative number (–4 in this case), we first must convert the number to 2's complement: The 2's complement of 4 is calculated as: +410: 0000 01002 -410: 1111 10112 (1's complement) +1 -410: 1111 11002 (2's complement) And the addition is: Carry: 1 1111 +1010: 0000 10102 - 410: 1111 11002 + 610: 1) 0000 01102 (2's complement) Where 1) is a carry bit that is dropped since there is no = 0000 01102 overflow after discarding the carry bit Click here to see the bit-by-bit progression of the addition. In the computer, it is possible for the sum of two numbers to exceed the largest number that can be held in a register. When this occurs, we have overflow, a condition similar to Figure 1-2. Figure 1-2 Overflow Condition Page 16 of 20 An overflow exists when the operation result overflows into the sign bit, causing the sign bit to be opposite to the sign bit of both numbers that are being added. See Example 1-17 for a case where an overflow exists. Example 1-17 An Example of an Overflow but 1000 00102 is equal to a large negative number (because the MSB is 1). There is an error because the sign of the result is not the same as the sign of the two numbers being added. In dealing with 2's complement addition of 8-bit numbers of opposite signs, there cannot be an overflow because the result can be guaranteed to be of lesser magnitude than the larger of the two numbers. It is possible for a carry bit to be generated in the 9 th position, but we use the lower order 8 bits and throw away the carry bit. Thus, the ninth bit from the right in Example 1-16 above is a carry bit and is discarded, giving us an answer of 0000 0110 2. In dealing with 2's complement addition of 8-bit numbers of the same sign, it is possible that the sum of the numbers, if big enough, will be larger than the largest number that can possibly be held in the register. When this occurs, a flag is set in the computer and it takes special steps to handle the problem. For the sake of simplicity, we will ignore this overflow condition and you will not be given any addition problems to solve where this overflow occurs. When the answer is the same sign as the two numbers being added, there is not an overflow. Example 1-18 Adding Positive and Negative Binary Numbers With a Negative Result (–10 + 4) The 2's complement of 10 is calculated as: +1010: 0000 10102 –1010: 1111 01012(1's complement) +1 –1010: 1111 01102 (2's complement) The addition is shown below: (There are no carries.) –1010: 1111 01102 – 410: 0000 01002 – 610: 1111 10102 –1010: – 410: – 610: 1111 0000 1111 01102 01002 10102 (2's complement) – 610 : 1111 10102 Click here to see the bit-by-bit progression of the addition. Page 17 of 20 The result is as it appears in the computer and is the answer to the problem. In order to evaluate the binary answer 1111 1010 in decimal, we take the 2's complement of the result, i.e.,: The number –0000 0110 is simply our way of evaluating the value of the 2's complement number. The answer in that form does not exist in the computer. Example 1-19 Adding Two Negative Numbers (-10 - 4) For this example, we will use the previously calculated 2's complements of 4 and 10. The addition is: (2's complement) (2's complement) where 1) is a carry bit that is dropped since there is no overflow after the carry bit is dropped = 1111 00102 Click here to see the bit-by-bit progression of the addition. The overflow bit is dropped because the answer is the same sign as the two numbers that were added. 4.3 Binary Multiplication and Division Multiplication and division of multiple-bit binary numbers follows the same approach as the multiplication and division of multiple-digit decimal numbers. In Example 1-20a, we show the longhand multiplication of the binary numbers for decimal 23 (called the multiplicand) times decimal 19 (called the multiplier). Example 1-20a Longhand Multiplication of Two Binary Numbers Decimal 23: x Decimal 19: 10111 10011 10111 10111 00000 00000 10111 110110101 (i.e., 10111 x 1) (i.e., 10111 x the 2nd 1) (i.e., 10111 x the 3rd 1) = decimal 437 Page 18 of 20 When multiplication is performed in the computer, the process is similar to that shown in Example 1-20b. The computer algorithm looks at each bit of the multiplier in turn, starting with the rightmost bit (known as the least significant bit, or LSB). If it was 1, we added the multiplicand to the total and then shifted (moved) the multiplicand one bit position to the left (i.e., add a zero to the right). If it was 0, we shifted the multiplicand one bit position to the left. The LSB of the multiplier is dropped. You are not required to know the algorithm for multiplication shown above, but you should understand that multiplication is performed by a series of adds and shifts of the multiplicand to the left. It should also be noted that multiplication requires two registers to hold the answer. Division is the opposite of multiplication. It is a series of subtractions and shifts of the divisor to the right. The answer is actually a tally of how many subtractions were made before each shift. The mechanics of multiplying and dividing by powers of 10 and 2 are interesting and worth looking at in order to understand how they are performed. To start, consider the following two sets of binary and decimal numbers: Table 1-8 Binary and Decimal Numeric Comparisons for Multiplication and Division Binary Decimal 101. 5 1010. 10 10100. 20 101000. 40 Binary 101. 10.1 1.01 .101 Decimal 5 2.5 1.25< .625 In the two left columns, each successive row of binary and decimal is multiplied by 2 (doubled). In binary, we can multiple by 2 (double) a number by adding a 0 to the right or by moving the decimal point one place to the right. This is multiplication. (A similar activity in decimal is adding one zero to the right in order to multiply by 10.) Notice that in the two right columns, each successive row is halved, or divided by 2. Thus, we can halve a binary number by moving the binary point one place to the left. To extend this concept, we can multiply by 2n by moving the binary point n places to the right, as shown in Example 1-21a. Example 1-21a Multiplying by 22 1012 x 22 (or decimal 4) = 101002 Likewise, we can divide by 2n by moving the binary point n places to the left, as shown in Examples 1-21b and 1-21c. Example 1-21b Dividing by 23 1010002/23 (or decimal 8) = 1012 and Example 1-21c Dividing by 22 1012/22 = 1.012 Page 19 of 20 Report broken links or any other problems on this page. Copyright © by University of Maryland University College . Page 20 of 20
© Copyright 2025 Paperzz