Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION. Data Representation in Computer Systems

Size: px
Start display at page:

Download "Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION. Data Representation in Computer Systems"

Transcription

1 There are 10 kinds of people in the world those who understand binary and those who don t. Anonymous 2CHAPTER Data Representation in Computer Systems 2.1 INTRODUCTION he organization of any computer depends considerably on how it represents T numbers, characters, and control information. The converse is also true: Standards ing, and conventions established over the years Jones have determined & Bartlett certain Learning, aspects of computer organization. This chapter describes the various ways in which computers OR DISTRIBUTION can store and manipulate numbers and characters. FOR SALE The ideas OR presented DISTRIBUTION in FOR SALE the following sections form the basis for understanding the organization and function of all types of digital systems. The most basic unit of information in a digital computer is called a bit, which is a contraction of binary digit. In the concrete sense, a bit is nothing more than s & Bartlett Learning, a state of on or off (or high Jones and low ) & Bartlett within Learning, a computer circuit. In 1964, the designers of the IBM System/360 FOR mainframe SALE OR computer DISTRIBUTION established a convention of using groups of 8 bits as the basic unit of addressable computer storage. They called this collection of 8 bits a byte. Computer words consist of two or more adjacent bytes that are sometimes addressed and almost always are manipulated collectively. The word size represents the Jones & Bartlett data size that Learning, is handled most efficiently by a particular Jones architecture. & Bartlett Learn Words FOR can SALE be 16 OR bits, DISTRIBUTION 32 bits, 64 bits, or any other size that makes FOR sense SALE in the OR DIST context of a computer s organization (including sizes that are not multiples of eight). An 8-bit byte can be divided into two 4-bit halves called nibbles (or nybbles). Because each bit of a byte has a value within a positional numbering system, the nibble containing the least-valued binary digit is called the low-order nibble, and the other half the high-order nibble.. 61

2 62 Chapter 2 / Data Representation in Computer Systems 2.2 POSITIONAL Jones & Bartlett NUMBERING Learning, SYSTEMS At some FOR point SALE during OR DISTRIBUTION the middle of the sixteenth century, Europe FOR embraced SALE OR DIST the decimal (or base 10) numbering system that the Arabs and Hindus had been using for nearly a millennium. Today, we take for granted that the number 243 means two hundreds, plus four tens, plus three units. Notwithstanding the fact that zero means nothing, virtually everyone knows that there Jones & Bartlett is a substantial Learning, difference between having 1 of Jones something & Bartlett and having Learning, 10 of FOR SALE something. OR DISTRIBUTION The general idea behind positional numbering systems is that a numeric value is represented through increasing powers of a radix (or base). This is often referred to as a weighted numbering system because each position is weighted by a power of the radix. The set of valid numerals for Jones a positional & Bartlett numbering Learning, system is equal in size to the radix of that system. For FOR example, SALE there OR are DISTRIBUTION 10 digits in the decimal system, 0 through 9, and 3 digits for the ternary (base 3) system, 0, 1, and 2. The largest valid number in a radix system is one smaller than the radix, so 8 is not a valid numeral in any radix system smaller than 9. To distinguish among numbers in different radices, we use the radix as a subscript, such as in Jones to & represent Bartlett Learning, the decimal number 33. (In this text, numbers Jones & written Bartlett Learn without FOR a SALE subscript OR should DISTRIBUTION be assumed to be decimal.) Any decimal FOR integer SALE OR DIST can be expressed exactly in any other integral base system (see Example 2.1). EXAMPLE 2.1 Three numbers are represented as powers of a radix. Jones & Bartlett Learning, = Jones 10 + & 1Bartlett 10 Learning, = = = = The two most important radices in computer science are binary (base two) and hexadecimal (base 16). Another radix FOR of SALE interest OR is octal DISTRIBUTION (base 8). The binary system uses only the digits 0 and 1; the octal system, 0 through 7. The hexadecimal system allows the digits 0 through 9 with A, B, C, D, E, and F being used to represent the numbers 10 through 15. Table 2.1 shows some of the radices. Jone 2.3 CONVERTING BETWEEN BASES Gottfried Leibniz ( ) was the first to generalize the idea of the (positional) decimal system to other bases. Being a deeply spiritual person, Leibniz Jones & Bartlett attributed Learning, divine qualities to the binary system. Jones He correlated & Bartlett the fact Learning, that any integer could be represented by a series of 1s and 0s with the idea that God (1) FOR SALE created OR DISTRIBUTION the universe out of nothing (0). Until the FOR first binary SALE digital OR DISTRIBUTION computers were built in the late 1940s, this system remained nothing more than a.

3 2.3 / Converting Between Bases 63 Powers of = 1 4 = = 1 2 = = = = = = = = = = = = = 32, = 65,536 Decimal 4-Bit Binary Hexadecimal A B C D E F TABLE 2.1 Some Numbers to Remember mathematical curiosity. Today, it lies at the heart of virtually every electronic device that relies on digital controls. ing, Because of its simplicity, the binary numbering Jones system & Bartlett translates Learning, easily into FOR SALE electronic OR DISTRIBUTION circuitry. It is also easy for humans to understand. FOR SALE Experienced OR DISTRIBUTION computer professionals can recognize smaller binary numbers (such as those shown in Table 2.1) at a glance. Converting larger values and fractions, however, usually requires a calculator or pencil and paper. Fortunately, the conversion techniques are easy to master with a little practice. We show a few of the simpler techniques s & Bartlett Learning, in the sections that follow Converting Unsigned Whole Numbers We begin with the base conversion of unsigned numbers. Conversion of signed numbers (numbers that can be positive or negative) is more complex, and it is important that you first understand the basic technique for conversion before continuing with signed numbers. FOR Conversion SALE between OR DISTRIBUTION base systems can be done by using either FOR repeated SALE sub-otraction or a division-remainder method. The subtraction method is cumbersome DIST and requires a familiarity with the powers of the radix being used. Because it is the more intuitive of the two methods, however, we will explain it first. As an example, let s say we want to convert to base 8. We know that Jones & Bartlett 8 3 Learning, = 512 is the highest power of 8 that is less than 538, so our base 8 number will be 4 digits wide (one for each power of the radix: 0 through 3). We make note that 512 goes once into 538 and subtract, leaving a difference of 26..

4 64 Chapter 2 / Data Representation in Computer Systems We Jones know & that Bartlett the next Learning, power of 8, 8 2 = 64, is too large to subtract, Jones so we & Bartlett note Learn the zero FOR placeholder SALE OR DISTRIBUTION and look for how many times 8 1 = 8 divides FOR 26. We SALE see OR DIST that it goes three times and subtract 24. We are left with 2, which is These steps are shown in Example 2.2. Jones & Bartlett EXAMPLE Learning, 2.2 Convert to base 8 using subtraction. FOR SALE OR 538 DISTRIBUTION = = = = 8 2 Jones & 0 Bartlett Learning, = The division-remainder method is faster and easier than the repeated subtraction method. It employs the idea that successive divisions by the base are in fact successive subtractions by powers of the base. The remainders that Jones & Bartlett we get Learning, when we sequentially divide by the base Jones end & up Bartlett being the Learning, digits of FOR SALE the OR result, DISTRIBUTION which are read from bottom to top. This FOR method SALE is OR illustrated DISTRIBUTION in Example 2.3. EXAMPLE 2.3 Convert to base 8 using the division-remainder method divides timeswith Jones & aremainderof2. Bartlett Learning, divides 67 8timeswith aremainderof divides 81time with aremainderof divides 10timeswith aremainderof1. Jones 0& Bartlett Learning, Reading FOR the SALE remainders OR DISTRIBUTION from bottom to top, we have: 538 = FOR SALE OR DIST 10 8 This method works with any base, and because of the simplicity of the calculations, it is particularly useful in converting from decimal to binary. Example 2.4 shows such a conversion..

5 2.3 / Converting Between Bases 65 Jones EXAMPLE & Bartlett 2.4 Convert Learning, to binary. FOR SALE 1 2 OR divides DISTRIBUTION timeswith aremainderof divides timeswith aremainderof divides timeswith aremainderof0. ing, divides 18 9timeswith aremainderof divides 94timeswith aremainderof divides 42timeswith aremainderof divides 21time with aremainderof divides 10timeswith Jones & aremainderof1. Bartlett Learning, 0 Reading the remainders from bottom to top, we have: = A binary number with N bits can represent unsigned integers from 0 to 2 N 1. Jones For example, & Bartlett 4 bits can Learning, represent the decimal values 0 through 15, Jones whereas & Bartlett 8 bits Learn can FOR represent SALE the OR values DISTRIBUTION 0 through 255. The range of values that can FOR be represented SALE OR DIST by a given number of bits is extremely important when doing arithmetic operations on binary numbers. Consider a situation in which binary numbers are 4 bits in length, and we wish to add (15 10 ) to We know that 15 plus 15 is 30, but 30 cannot be represented using only 4 bits. This is an example of a condition known Jones & Bartlett as overflow, Learning, which occurs in unsigned binary representation Jones & Bartlett when the Learning, result of an FOR SALE arithmetic OR DISTRIBUTION operation is outside the range of allowable FOR precision SALE for OR the DISTRIBUTION given number of bits. We address overflow in more detail when discussing signed numbers in Section 2.4. s & Bartlett Learning, Converting Fractions Fractions in any base system can be FOR approximated SALE OR in any DISTRIBUTION other base system using negative powers of a radix. Radix points separate the integer part of a number from its fractional part. In the decimal system, the radix point is called a decimal point. Binary fractions have a binary point. Fractions that contain repeating strings of digits to the right of the radix point Jones in & base Bartlett may not Learning, necessarily have a repeating sequence of Jones digits in & another Bartlett Learn base. FOR For SALE instance, OR 2 DISTRIBUTION is a repeating decimal fraction, but in the ternary FOR system, SALE it OR DIST 3 1 terminates as 0.23(2 3 = ). We can convert fractions between different bases using methods analogous to the repeated subtraction and division-remainder methods for converting integers. Example 2.5 shows how we can use repeated subtraction to convert a number from decimal to base 5..

6 66 Chapter 2 / Data Representation in Computer Systems EXAMPLE Jones & Bartlett 2.5 Convert Learning, to base 5. FOR SALE OR DISTRIBUTION = = 5 0 (A placeholder) Jones & Bartlett Learning, FOR SALE OR DISTRIBUTION = = Reading from top to bottom, we have: = Because the remainder method works with positive powers of the radix for conversion of integers, it stands to reason that we would use multiplication to convert fractions, because they are expressed in negative powers of the radix. However, instead of looking for remainders, as we did above, we use only the integer part of the FOR product SALE after OR multiplication DISTRIBUTION by the radix. The answer is read FOR from top SALE to OR DIST bottom instead of bottom to top. Example 2.6 illustrates the process. EXAMPLE 2.6 Convert to base 5. Jones & Bartlett.4304 Learning, FOR SALE OR DISTRIBUTION Theinteger part is 2. Omit fromsubsequent multiplication Theinteger part is 0. Jones We ll need & Bartlett it as aplaceholder. Learning, Theinteger part is 3. Omit fromsubsequent multiplication FOR 5 SALE OR DISTRIBUTION The fractionalpartisnow zero, so we are done. Reading from top to bottom, we have = This example was contrived so that the process would stop after a few steps. FOR SALE Often OR things DISTRIBUTION don t work out quite so evenly, and we FOR end up SALE with repeating OR DISTRIBUTION fractions. Most computer systems implement specialized rounding algorithms to.

7 2.3 / Converting Between Bases 67 Jones provide & a Bartlett predictable Learning, degree of accuracy. For the sake of clarity, Jones however, & Bartlett we Learn will simply discard (or truncate) our answer when the desired accuracy has been achieved, as shown in Example 2.7. EXAMPLE 2.7 Convert to binary with 4 bits to the right of the binary Jones & Bartlett point. Learning, (Anotherplaceholder) Jones & Bartlett 2 Learning, FOR SALE (Thisis OR DISTRIBUTION our fourth bit. Wewill stop here.) Reading from top to bottom, = to four binary places. Jones & Bartlett The Learning, methods just described can be used to directly Jones convert & Bartlett any number Learning, any base to any other base, say from base 4 to base 3 (as in Example 2.8). However, in FOR SALE most OR DISTRIBUTION cases, it is faster and more accurate to first convert FOR to SALE base 10 OR and DISTRIBUTION then to the desired base. One exception to this rule is when you are working between bases that are powers of two, as you ll see in the next section. EXAMPLE 2.8 Convert to base 3. First, convert to decimal: 3121 = = = 217 Then convert to base 3: Wehave 3121 = 22,

8 68 Chapter 2 / Data Representation in Computer Systems Converting Jones & Bartlett Between Learning, Power-of-Two Radices Binary FOR numbers SALE are OR often DISTRIBUTION expressed in hexadecimal and sometimes FOR octal to SALE OR DIST improve their readability. Because 16 = 2 4, a group of 4 bits (called a hextet) is easily recognized as a hexadecimal digit. Similarly, with 8 = 2 3, a group of 3 bits (called an octet) is expressible as one octal digit. Using these relationships, we can therefore convert a number from binary to octal or hexadecimal by doing lit- Jones & Bartlett more Learning, than looking at it. EXAMPLE 2.9 Convert to octal and hexadecimal Separate into groups of 3 bits for the octal conversion = Separate into groups of 4for the hexadecimal conversion. C 9 D = C9D16 If there are too few bits, leading 0s can be added. 2.4 SIGNED INTEGER REPRESENTATION Jones & Bartlett We have Learning, seen how to convert an unsigned integer Jones from & one Bartlett base to Learning, another. Signed numbers require that additional issues be addressed. When an integer variable is declared in a program, many programming languages automatically allocate a storage area that includes a sign as the first bit of the storage location. By convention, a 1 in the high-order bit indicates a negative number. The storage location can be as small as an 8-bit byte or as large as several words, depending s & Bartlett Learning, on the programming language and Jones the computer & Bartlett system. Learning, The remaining bits (after the sign bit) are used to represent the number itself. How this number is represented depends FOR SALE on the OR method DISTRIBUTION used. There are three commonly used approaches. The most intuitive method, signed magnitude, uses the remaining bits to represent the magnitude of the number. This method and the other two approaches, which both use the concept of complements, are introduced Jones in the & Bartlett following Learning, sections Signed Magnitude Up to this point, we have ignored the possibility of binary representations for negative numbers. The set of positive and negative integers is referred to as the set of signed integers. The problem with representing signed integers as binary Jones & Bartlett values Learning, is the sign how should we encode the actual Jones sign & of Bartlett the number? Learning, Signedmagnitude OR DISTRIBUTION representation is one method of solving FOR this SALE problem. OR As DISTRIBUTION its name FOR SALE implies, a signed-magnitude number has a sign as its leftmost bit (also referred.

9 2.4 / Signed Integer Representation 69 Jones to as the & Bartlett high-order Learning, bit or the most significant bit), whereas the Jones remaining & Bartlett bits Learn represent the magnitude (or absolute value) of the numeric value. For example, in an 8-bit word, 1 would be represented as , and +1 as In a computer system that uses signed-magnitude representation and 8 bits to store integers, 7 bits can be used for the actual representation of the magnitude of the 7 number. This means that the largest integer an 8-bit word can represent is 2 1, Jones & Bartlett or 127 Learning, (a 0 the high-order bit, followed by 7 1s). Jones The smallest & Bartlett integer Learning, is 8 1s, or ( N 1) ( N FOR SALE 127. OR DISTRIBUTION Therefore, N bits can represent (2 1) FOR to 2 SALE 1) 1. OR DISTRIBUTION Computers must be able to perform arithmetic calculations on integers that are represented using this notation. Signed-magnitude arithmetic is carried out using essentially the same methods that humans use with pencil and paper, but it can get confusing very quickly. As an example, consider the rules s & Bartlett Learning, for addition: (1) If the signs Jones are the & same, Bartlett add the Learning, magnitudes and use that same sign for the result; (2) If FOR the signs SALE differ, OR you DISTRIBUTION must determine which operand has the larger magnitude. The sign of the result is the same as the sign of the operand with the larger magnitude, and the magnitude must be obtained by subtracting (not adding) the smaller one from the larger one. If you consider these rules carefully, this is the method you use for signed arithmetic by & hand. Bartlett Learning, Jones FOR We arrange SALE the OR operands DISTRIBUTION in a certain way based on their signs, FOR perform SALE the OR DIST calculation without regard to the signs, and then supply the sign as appropriate when the calculation is complete. When modeling this idea in an 8-bit word, we must be careful to include only 7 bits in the magnitude of the answer, discarding any carries that take place over the high-order bit. FOR SALE EXAMPLE OR DISTRIBUTION 2.10 Add to using FOR signed-magnitude SALE OR DISTRIBUTION arithmetic carries ( 79) (35) (114) The arithmetic proceeds just as in decimal addition, including the carries, until we get to the seventh bit from the right. If there is a carry here, we say that we have an overflow condition and the carry is discarded, resulting in an incorrect Jones sum. There & Bartlett is no overflow Learning, this example. We find that = in signed-magnitude representation. Sign bits are segregated because they are relevant only after the addition is complete. Learning, In this case, we have the sum of two positive Jones numbers, & Bartlett which Learning, is positive. Jones & Bartlett FOR SALE Overflow OR DISTRIBUTION (and thus an erroneous result) in signed FOR numbers SALE occurs OR when DISTRIBUTION the sign of the result is incorrect..

10 70 Chapter 2 / Data Representation in Computer Systems Jones In signed & Bartlett magnitude, Learning, the sign bit is used only for the sign, so Jones we can t & carry Bartlett Learn into it. If there is a carry emitting from the seventh bit, our result will be truncated as the seventh bit overflows, giving an incorrect sum. (Example 2.11 illus- trates this overflow condition.) Prudent programmers avoid million-dollar mistakes by checking for overflow conditions whenever there is the slightest possibility they could occur. If we did not discard the overflow bit, it would carry Jones & Bartlett into the Learning, sign, causing the more outrageous result Jones of the sum & Bartlett of two positive Learning, numbers being negative. (Imagine what would happen if the next step in a program were to take the square root or log of that result!) EXAMPLE 2.11 Add to using signed-magnitude arithmetic. Last carry 1 Jones 1 & 1 Bartlett 1 1 Learning, carries overflowsand FOR 0 1SALE 1 1 OR 1 DISTRIBUTION ( 79) is discarded (99) ( 50) We obtain the erroneous result of = 50. Dabbling on the Double Jones & Bartlett The fastest Learning, way to convert a binary number to decimal Jones is a method & Bartlett called Learning, doubledabble OR DISTRIBUTION (or double-dibble). This method builds on the idea FOR that SALE a subsequent OR DISTRIBUTION power FOR SALE of two is double the previous power of two in a binary number. The calculation starts with the leftmost bit and works toward the rightmost bit. The first bit is doubled and added to the next bit. This sum is then doubled and added to the following bit. The process is repeated for each bit until the rightmost bit has been used. EXAMPLE 1 Convert to decimal. Step 1: Write downthe binary number, leaving space between thebits. Jones & 1Bartlett 0 0 Learning, Step 2: Double the high-order bit and copy it under the next bit ing, 2 2.

11 2.4 / Signed Integer Representation 71 Step 3: Add the next bit and double the sum. Copy this result under the next bit Step 4: Repeat Step 3 until yourun outofbits FOR + 1SALE OR DISTRIBUTION The answer: = FOR When SALE we combine OR DISTRIBUTION hextet grouping (in reverse) with the double-dabble FOR method, SALE OR DIST we find that we can convert hexadecimal to decimal with ease. EXAMPLE 2 Convert 02CA 16 to decimal. First, convert the hex to binary by grouping into hextets. 0 2 C A Jones & Bartlett Learning, Then apply the double-dabble method on the binary form: CA = =

12 72 Chapter 2 / Data Representation in Computer Systems As Jones with addition, & Bartlett signed-magnitude Learning, subtraction is carried out in a Jones manner & similar Bartlett Learn to pencil-and-paper decimal arithmetic, where it is sometimes necessary to borrow from digits in the minuend. EXAMPLE 2.12 Subtract from using signed-magnitude Jones & Bartlett arithmetic. Learning, borrows ( 99) (79) ( 20) We find that = in signed-magnitude representation. EXAMPLE Jones & Bartlett 2.13 Subtract Learning, (99) from (79) Jones using & signedmagnitude FOR SALE arithmetic. OR DISTRIBUTION Bartlett Learn By inspection, we see that the subtrahend, , is larger than the minuend, With the result obtained in Example 2.12, we know that the difference of these two numbers is Because the subtrahend is larger than the minuend, all we need to do is change the sign of the difference. So we find Jones & Bartlett that Learning, = in signed-magnitude Jones & Bartlett representation. Learning, We know that subtraction is the same as adding the opposite, which equates to negating the value we wish to subtract and then adding instead (which is often much easier than performing all the borrows necessary for subtraction, particularly in dealing with binary numbers). Jones Therefore, & Bartlett we need Learning, to look at some examples involving both positive and negative FOR numbers. SALE OR Recall DISTRIBUTION the rules for addition: (1) If the signs are the same, add the magnitudes and use that same sign for the result; (2) If the signs differ, you must determine which operand has the larger magnitude. The sign of the result is the same as the sign of the operand with the larger magnitude, and the magnitude must be obtained by subtracting (not adding) the Jones smaller & one Bartlett from the Learning, larger one. EXAMPLE 2.14 Add ( 19) to (+13) using signedmagnitude arithmetic. The first number (the augend) is negative because its sign bit is set to 1. Jones & Bartlett The second Learning, number (the addend) is positive. What Jones we & are Bartlett asked to Learning, do is FOR SALE fact OR a DISTRIBUTION subtraction. First, we determine which of the FOR two SALE numbers OR is DISTRIBUTION larger in.

13 2.4 / Signed Integer Representation 73 Jones magnitude & Bartlett and use Learning, that number for the augend. Its sign will be Jones the sign & Bartlett of the Learn result ing, FOR SALE OR 1DISTRIBUTION borrows ( 19) + (13) Jone ( 6) FO With the inclusion of the sign bit, we see that = in signed-magnitude representation. EXAMPLE 2.15 Subtract ( 24) from (-43) using signed-magnitude arithmetic. We can convert the subtraction to an addition by negating -24, which gives us 24, and then we can add this to -43, giving us a new problem of Jones However, & Bartlett we know Learning, from the addition rules above that because Jones the signs & Bartlett now Learn differ, FOR we SALE must actually OR DISTRIBUTION subtract the smaller magnitude from the FOR larger SALE magni-otude (or subtract 24 from 43) and make the result negative (because 43 is larger DIST than 24). 0 2 ing, FOR SALE OR DISTRIBUTION ( 43) (24) ( 19) Note that we are not concerned with the sign until we have performed the s & Bartlett Learning, subtraction. We know the answer Jones must & Bartlett be negative. Learning, So we end up with = FOR in SALE signed-magnitude OR DISTRIBUTION representation While reading the preceding examples, you may have noticed how many questions we had to ask ourselves: Which number is larger? Am I subtracting a Jones negative & number? Bartlett How Learning, many times do I have to borrow from Jones the minuend? & Bartlett Learn A FOR computer SALE engineered OR DISTRIBUTION to perform arithmetic in this manner must FOR make SALE just as OR DIST many decisions (though a whole lot faster). The logic (and circuitry) is further complicated by the fact that signed magnitude has two representations for 0, and (And mathematically speaking, this simply shouldn t happen!) Simpler methods for representing signed numbers would allow for Jones & Bartlett simpler Learning, and less expensive circuits. These simpler Jones methods & Bartlett are based Learning, on radix FOR SALE complement OR DISTRIBUTION systems..

14 74 Chapter 2 / Data Representation in Computer Systems Complement Jones & Bartlett Systems Learning, Number FOR theorists SALE OR have DISTRIBUTION known for hundreds of years that one decimal FOR number SALE OR DIST can be subtracted from another by adding the difference of the subtrahend from all nines and adding back a carry. This is called taking the nine s complement of the subtrahend or, more formally, finding the diminished radix complement of the subtrahend. Let s say we wanted to find Taking the difference Jones & Bartlett of 52 Learning, from 999, we have 947. Thus, in nine s complement Jones & Bartlett arithmetic, Learning, we have FOR SALE 167 OR 52 DISTRIBUTION = = The carry from the FOR hundreds SALE column OR DISTRIBUTION is added back to the units place, giving us a correct = 115. This method was commonly called casting out 9s and has been extended to binary operations to simplify computer arithmetic. The advantage that complement systems give us over signed magnitude is that there is no need to process sign bits separately, but s & Bartlett Learning, we can still easily check the sign Jones of a number & Bartlett by looking Learning, at its high-order bit. Another way to envision complement FOR systems SALE OR is to DISTRIBUTION imagine an odometer on a bicycle. Unlike cars, when you go backward on a bike, the odometer will go backward as well. Assuming an odometer with three digits, if we start at zero and end with 700, we can t be sure whether the bike went forward 700 miles or backward 300 miles! The easiest solution to this dilemma is simply to cut the number Jones space & Bartlett in half and Learning, use for positive miles and Jones for & negative FOR miles. SALE We have, OR effectively, DISTRIBUTION cut down the distance our odometer can FOR measure. SALE OR DIST Bartlett Learn But now if it reads 997, we know the bike has backed up 3 miles instead of riding forward 997 miles. The numbers represent the radix complements (the second of the two methods introduced below) of the numbers and are being used to represent negative distance. FOR SALE One s OR Complement DISTRIBUTION As illustrated above, the diminished radix complement of a number in base 10 is found by subtracting the subtrahend from the base minus one, which is 9 in decimal. More formally, given a number N in base r having d digits, the diminished d radix complement of N is defined to be ( r 1) N. For decimal numbers, r = 10, s & Bartlett Learning, and the diminished radix is 10 1 Jones = 9. For & Bartlett example, Learning, the nine s complement of 2468 is = For an FOR equivalent SALE operation OR DISTRIBUTION in binary, we subtract from one less the base (2), which is 1. For example, the one s complement of is = Although we could tediously borrow and subtract as discussed above, a few experiments will convince you that forming the one s complement of a binary number amounts to nothing more than switching all of the 1s with 0s Jones and vice & versa. Bartlett This Learning, sort of bit-flipping is very simple to implement Jones in computer & Bartlett Learn hardware. FO It is important to note at this point that although we can find the nine s complement of any decimal number or the one s complement of any binary number, we are most interested in using complement notation to represent negative numbers. We know that performing a subtraction, such as 10 7, can also be thought Jones & Bartlett of as Learning, adding the opposite, as in 10 + ( 7). Complement Jones & notation Bartlett allows Learning, us to FOR SALE simplify OR DISTRIBUTION subtraction by turning it into addition, but FOR it also SALE gives us OR a method DISTRIBUTION to represent negative numbers. Because we do not wish to use a special bit to represent the sign (as we did in signed-magnitude representation), we need to.

15 2.4 / Signed Integer Representation 75 Jones remember & Bartlett that if a Learning, number is negative, we should convert it to Jones its complement. & Bartlett Learn The result should have a 1 in the leftmost bit position to indicate that the number is negative. Although the one s complement of a number is technically the value obtained by subtracting that number from a large power of two, we often refer to a computer using one s complement for negative numbers as a one s complement system Jones & Bartlett or as Learning, a computer that uses one s complement arithmetic. Jones & Bartlett This can be Learning, somewhat misleading, as positive numbers do not need to be complemented; we only complement negative numbers so we can get them into a format the computer will understand. Example 2.16 illustrates these concepts. EXAMPLE 2.16 Express and in 8-bit binary, assuming a computer is s & Bartlett Learning, using one s complement representation = + ( ) = FO 2 9 = = ( ) Jones Unlike & signed Bartlett magnitude, Learning, one s complement addition there is Jones no need & to Bartlett maintain FOR the sign SALE bit OR separate DISTRIBUTION from the other bits. The sign takes care of FOR itself. SALE Com-OR DIST Learn pare Example 2.17 with Example EXAMPLE 2.17 Add to using one s complement addition Jones carrie FOR SALE ( 79) OR DISTRIBUTION (35) ( 114) s & Bartlett Learning, Suppose we wish to subtract 9 Jones from 23. & To Bartlett carry out Learning, a one s complement subtraction, we first express the subtrahend FOR (9) SALE in one s OR complement, DISTRIBUTION then add it to the minuend (23); we are effectively now adding -9 to 23. The high-order bit will have a 1 or a 0 carry, which is added to the low-order bit of the sum. (This is called end carry-around and results from using the diminished radix complement.) EXAMPLE 2.18 Add to using one s complement arithmetic carries ( 23) ( 9) Thelast Jones 0 1 & Bartlett Learning, carry is added + 1 to thesum

16 76 Chapter 2 / Data Representation in Computer Systems EXAMPLE Jones & Bartlett 2.19 Add Learning, 9 10 to using one s complement arithmetic. Thelast FOR SALE OR 0 DISTRIBUTION ( 9) FOR SALE OR DIST carry is ( 23) so we are done How do we know that is actually ? We simply need to take the one s complement of this binary number (remembering it must be negative because the leftmost bit is negative). The one s complement of is , which is 14. The primary disadvantage of Jones one s complement & Bartlett is Learning, that we still have two representations for 0: and FOR SALE For this OR and DISTRIBUTION other reasons, computer engineers long ago stopped using one s complement in favor of the more efficient two s complement representation for binary numbers. Two s Complement Two s Jones complement & Bartlett is Learning, an example of a radix complement. Given Jones a number & Bartlett N in Learn base FOR d r having SALE d digits, OR the DISTRIBUTION radix complement of N is defined as r NFOR for N SALE 0 OR DIST and 0 for N = 0. The radix complement is often more intuitive than the diminished radix complement. Using our odometer example, the ten s complement of 3 going forward 2 miles is 10 2= 998, which we have already agreed indicates a negative (backward) distance. Similarly, in binary, the two s complement of the Jones & Bartlett 4 4-bit number Learning, is = Jones 2 = 1101 & Bartlett 2. Learning, FOR SALE OR Upon DISTRIBUTION closer examination, you will discover that two s FOR complement SALE OR is DISTRIBUTION nothing more than one s complement incremented by 1. To find the two s complement of a binary number, simply flip bits and add 1. This simplifies addition and subtraction as well. Because the subtrahend (the number we complement and add) is incremented at the outset, however, there is no end carry-around to worry about. We s & Bartlett Learning, simply discard any carries involving Jones the high-order & Bartlett bits. Learning, Just as with one s complement, two s complement refers to the complement FOR SALE of OR a number, DISTRIBUTION whereas a computer using this notation to represent negative numbers is said to be a two s complement system, or a computer that uses two s complement arithmetic. As before, positive numbers can be left alone; we only need to complement negative numbers to get them into their two s complement form. Example 2.20 illustrates these concepts. EXAMPLE 2.20 Express 23 10, , and in 8-bit binary, assuming a computer is using two s complement representation =+ ( ) = Jones & Bartlett 23 Learning, 10 = ( ) = = Jones & 2 Bartlett Learning, FOR SALE OR 9 DISTRIBUTION = = = FO ( )

17 2.4 / Signed Integer Representation 77 Jones Because & the Bartlett representation Learning, of positive numbers is the same in one s Jones complement & Bartlett Learn and two s complement (as well as signed-magnitude), the process of adding two positive binary numbers is the same. Compare Example 2.21 with Example 2.17 and Example Jones & Bartlett Null Learning, Pointers: Tips and Hints You should have a fairly good idea by now of why we need to study the different formats. If numeric values will never be negative (only positive or zero values are used, such as for someone s age), unsigned numbers are used. The advantage to using an unsigned format is that the number of positive values that can be represented is s & Bartlett Learning, larger (no bits are used for the sign). Jones For example, & Bartlett if we Learning, are using 4 bits to represent unsigned integers, we can represent FOR values SALE from 0 OR to 15. DISTRIBUTION However, if we are using signed magnitude representation, the bits are interpreted differently, and the range becomes -7 to +7. If the numeric values can be positive or negative, we need to use a format that can represent both. Converting unsigned whole numbers tends to be relatively Jones straightforward, & Bartlett but for Learning, signed numbers, in particular, complement Jones systems & can Bartlett be Learn confusing. FOR SALE Because OR we DISTRIBUTION talk about converting a binary number into a FOR signed SALE two s OR DIST complement by padding it with 0s to the proper length, and then flipping the bits and adding one, people often think that all numbers are converted this way. For example, if someone is asked how a computer, using two s complement representation, would represent -6 (assuming 4-bit values), they answer: 1010 (take 0110, toggle each bit, Jones & Bartlett and Learning, add 1). This is, of course, the correct answer. Jones However, & Bartlett if that same Learning, person is FOR SALE asked OR DISTRIBUTION how the computer, using two s complement representation, FOR SALE would OR DISTRIBUTION represent +6, they will often do exactly the same thing, giving the same answer, which is incorrect. The value +6 using 4 bits is The same is true if we are converting from two s complement to decimal: If the binary value is 0111, then its equivalent decimal value is simply 7 (no bit flipping required!). However, if the value is 1010, this represents a s & Bartlett Learning, negative value, so we would flip the Jones bits (0101), & Bartlett add 1 (0110), Learning, and see that this binary value represents -6. It is important to realize that representing positive numbers does not require any conversion at all! It is only when a number is negative that two s complement, signed magnitude, and one s complement representations are necessary. A positive number on a computer that uses signed magnitude, a positive number on a computer that uses Jones one s complement, & Bartlett and Learning, a positive number on a computer that uses two s Jones complement & Bartlett Learn will FOR be exactly SALE the same. OR DISTRIBUTION If a computer uses n bits to represent integers, it can FOR represent SALE OR DIST 2 n different values (because there are 2 n different bit patterns possible); the computer (and even you!) have no way to know whether a particular bit pattern is unsigned or signed simply by looking at the number. It is up to the programmer to make sure the bit string is interpreted correctly..

18 78 Chapter 2 / Data Representation in Computer Systems EXAMPLE Jones & Bartlett 2.21 Add Learning, to using two s complement Jones addition. & Bartlett Learn FOR SALE OR 1 1DISTRIBUTION 1 1 carries ( 79) (35) ( 114) Suppose we are given the binary representation for a number and we want to know its decimal equivalent. Positive numbers are easy. For example, to convert the two s complement value of to decimal, we simply convert this binary number to a decimal number to get 23. However, converting two s complement negative numbers requires a reverse procedure similar to the conversion from decimal to binary. Suppose we are given FOR the SALE two s OR complement DISTRIBUTION binary value of , and we want to know the decimal equivalent. We know this is a negative number but must remember it is represented using two s complement notation. We first flip the bits and then add 1 (find the one s complement and add 1). This results in the following: = This is equivalent to the decimal value 9. However, the original number we started with was negative, so we FOR end up SALE with OR -9 as DISTRIBUTION the decimal equivalent to The following two examples illustrate how to perform addition (and hence subtraction, because we subtract a number by adding its opposite) using two s complement notation. Jones & Bartlett EXAMPLE Learning, 2.22 Add 9 10 to using two s Jones complement & Bartlett arithmetic. Learning, (9) ( 23) It is left as an exercise for you to verify FOR that SALE OR DISTRIBUTION 2 is actually using two s complement notation. EXAMPLE 2.23 Find the sum of and in binary using two s complement arithmetic. Jone FOR SALE 1 OR 1 DISTRIBUTION carries ( 23) Discard carry ( 9) In two s complement, the addition of two negative numbers produces a negative number, as we might expect..

19 2.4 / Signed Integer Representation 79 Jones EXAMPLE & Bartlett 2.24 Learning, Find the sum of (-23) and Jones 2 (-9) & Bartlett using Learn two s FOR complement SALE OR addition. DISTRIBUTION carries ( 23) Discard carry ( 9) Jones ( 32) & Bartlett Learning, Notice that the discarded carries in Examples 2.23 and 2.24 did not cause an erroneous result. An overflow occurs if two positive numbers are added and the result s & Bartlett Learning, is negative, or if two negative Jones numbers & are Bartlett added and Learning, the result is positive. It is not possible to have overflow when FOR using SALE two s complement OR DISTRIBUTION notation if a positive and a negative number are being added together. Simple computer circuits can easily detect an overflow condition using a rule that is easy to remember. You ll notice in both Examples 2.23 and 2.24 that the carry going into the sign bit (a 1 is carried from the previous bit position into the sign bit Jones position) & is Bartlett the same Learning, as the carry going out of the sign bit (a 1 Jones is carried & out Bartlett and Learn discarded). FOR SALE When OR these DISTRIBUTION carries are equal, no overflow occurs. When FOR they differ, SALE an OR DIST overflow indicator is set in the arithmetic logic unit, indicating the result is incorrect. A Simple Rule for Detecting an Overflow Condition in Signed Numbers: If the carry into the sign bit equals the carry out of the bit, no overflow has occurred. If the carry into the sign bit is different from the carry out of the sign bit, overflow (and thus an error) has occurred. The hard part is getting programmers (or compilers) to consistently check for the overflow condition. Example 2.25 indicates overflow because the carry into the sign bit (a 1 is carried in) is not equal to the carry out of the sign bit (a 0 is carried out). s & Bartlett Learning, EXAMPLE 2.25 Find the sum Jones of & and Bartlett 8 10 in binary Learning, using two s complement arithmetic carries ( 126) Discard last ( 8) carry ing, ( 122???) A 1 is carried into the leftmost bit, but a 0 is carried out. Because these carries are not equal, an overflow has occurred. (We can easily see that two positive numbers are being added but the result is negative.) We return to this topic in Section Two s complement is the most popular choice for representing signed numbers. The algorithm for adding and subtracting is quite easy, has the best representation for 0 (all 0 bits), is self-inverting, and is easily extended to larger numbers.

20 80 Chapter 2 / Data Representation in Computer Systems INTEGER MULTIPLICATION FOR SALE OR AND DISTRIBUTION DIVISION Unless sophisticated algorithms are used, multiplication and division can consume a considerable number of computation cycles before a result is obtained. Here, we discuss only the most straightforward approach to these operations. In real systems, dedicated hardware is used to optimize Jones throughput, & Bartlett sometimes Learning, carry- ing out portions of the calculation in parallel. Curious readers will want to investigate some of these advanced methods in the references cited at the end of this chapter. The simplest multiplication algorithms used by computers are similar to traditional pencil-and-paper methods used by humans. The complete multiplication s & Bartlett Learning, table for binary numbers couldn t Jones be simpler: & Bartlett zero times Learning, any number is zero, and one times any number is that number. To illustrate simple computer multiplication, we begin by writing the multiplicand and the multiplier to two separate storage areas. We also need a third storage area for the product. Starting with the low-order bit, a pointer is set to each digit of the multiplier. For each digit in the multiplier, the multiplicand is shifted one bit Jones to the & left. Bartlett When the Learning, multiplier is 1, the shifted multiplicand Jones is added & Bartlett to a Learn running sum of partial products. Because we shift the multiplicand by one bit for each bit in the multiplier, a product requires double the working space of either the multiplicand or the multiplier. There are two simple approaches to binary division: We can either iteratively subtract the denominator from the divisor, or we can use the same trial-and-error Jones & Bartlett method Learning, of long division that we were taught in grade Jones school. & Bartlett As with multiplication, the most efficient methods used for binary division are beyond the scope of Learning, this text and can be found in the references at the end of this chapter. Regardless of the relative efficiency of any algorithms that are used, division is an operation that can always cause a computer to crash. This is the case of bits. The biggest drawback is in FOR the asymmetry SALE OR seen DISTRIBUTION in the range of values that can be represented by N bits. With signed-magnitude numbers, for example, 4 bits allow us to represent the values -7 through +7. However, using two s complement, we can represent the values -8 through +7, which is often confusing to anyone learning about complement representations. To see why +7 is the largest number we can represent using 4-bit two s complement representation, we need FOR only SALE remember OR DISTRIBUTION that the first bit must be 0. If the remaining FOR bits are SALE all OR DIST 1s (giving us the largest magnitude possible), we have , which is 7. An immediate reaction to this is that the smallest negative number should then be , but we can see that is actually -1 (flip the bits, add 1, and make Jones & Bartlett the number Learning, negative). So how do we represent -8 Jones in two s & complement Bartlett Learning, notation using 4 bits? It is represented as We know this is a negative number. If FOR SALE we OR flip DISTRIBUTION the bits (0111), add 1 (to get 1000, which FOR is 8), SALE and make OR it DISTRIBUTION negative, we get -8..

21 2.4 / Signed Integer Representation 81 particularly FOR SALE when OR division DISTRIBUTION by zero is attempted or when two numbers FOR of SALE enor-omously different magnitudes are used as operands. When the divisor is much DIST smaller than the dividend, we get a condition known as divide underflow, which the computer sees as the equivalent of division by zero, which is impossible. Computers make a distinction between integer division and floating-point Jones & Bartlett division. Learning, With integer division, the answer comes Jones in two & Bartlett parts: a quotient Learning, and FOR SALE a OR remainder. DISTRIBUTION Floating-point division results in a FOR number SALE that OR is expressed DISTRIBUTION as a binary fraction. These two types of division are sufficiently different from each other as to warrant giving each its own special circuitry. Floating-point calculations are carried out in dedicated circuits called floating-point units, or FPUs. EXAMPLE Find the product of FOR SALE 2 and OR DISTRIBUTION 2. Multiplicand = Partial products Add multiplicand and shift left. Add multiplicand and shift left. Don t add, just shift multiplicand left. Add multiplicand FOR ProductSALE OR DISTRIBUTION Excess-M Representation for Signed FOR SALE Numbers OR DISTRIBUTION Recall the bicycle example that we discussed when introducing complement systems. We selected a particular value (500) as the cutoff for positive miles, and we assigned values from 501 to 999 to negative miles. We didn t need signs because we used the range to determine whether the number was positive or negative. Excess-M representation (also called offset binary representation) does something FOR very SALE similar; OR unsigned DISTRIBUTION binary values are used to represent signed FOR integers. SALE OR DIST However, excess-m representation, unlike signed magnitude and the complement encodings, is more intuitive because the binary string with all 0s represents the smallest number, whereas the binary string with all 1s represents the largest Jones & Bartlett value; Learning, in other words, ordering is preserved. The unsigned binary representation for integer M (called the bias) represents FOR SALE the OR value DISTRIBUTION 0, whereas all 0s in the bit pattern represents FOR SALE the integer OR -M. DISTRIBUTION Essentially, a decimal integer is mapped (as in our bicycle example) to an unsigned.

Chapter 2. Data Representation in Computer Systems

Chapter 2. Data Representation in Computer Systems Chapter 2 Data Representation in Computer Systems Chapter 2 Objectives Understand the fundamentals of numerical data representation and manipulation in digital computers. Master the skill of converting

More information

Chapter 2: Number Systems

Chapter 2: Number Systems Chapter 2: Number Systems Logic circuits are used to generate and transmit 1s and 0s to compute and convey information. This two-valued number system is called binary. As presented earlier, there are many

More information

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM 1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM 1.1 Introduction Given that digital logic and memory devices are based on two electrical states (on and off), it is natural to use a number

More information

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR UNIT I Digital Systems: Binary Numbers, Octal, Hexa Decimal and other base numbers, Number base conversions, complements, signed binary numbers, Floating point number representation, binary codes, error

More information

DIGITAL SYSTEM FUNDAMENTALS (ECE 421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE 422) COURSE / CODE NUMBER SYSTEM

DIGITAL SYSTEM FUNDAMENTALS (ECE 421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE 422) COURSE / CODE NUMBER SYSTEM COURSE / CODE DIGITAL SYSTEM FUNDAMENTALS (ECE 421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE 422) NUMBER SYSTEM A considerable subset of digital systems deals with arithmetic operations. To understand the

More information

CHAPTER 2 Data Representation in Computer Systems

CHAPTER 2 Data Representation in Computer Systems CHAPTER 2 Data Representation in Computer Systems 2.1 Introduction 37 2.2 Positional Numbering Systems 38 2.3 Decimal to Binary Conversions 38 2.3.1 Converting Unsigned Whole Numbers 39 2.3.2 Converting

More information

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation Data Representation II CMSC 313 Sections 01, 02 The conversions we have so far presented have involved only unsigned numbers. To represent signed integers, computer systems allocate the high-order bit

More information

Module 2: Computer Arithmetic

Module 2: Computer Arithmetic Module 2: Computer Arithmetic 1 B O O K : C O M P U T E R O R G A N I Z A T I O N A N D D E S I G N, 3 E D, D A V I D L. P A T T E R S O N A N D J O H N L. H A N N E S S Y, M O R G A N K A U F M A N N

More information

CHAPTER 2 Data Representation in Computer Systems

CHAPTER 2 Data Representation in Computer Systems CHAPTER 2 Data Representation in Computer Systems 2.1 Introduction 37 2.2 Positional Numbering Systems 38 2.3 Decimal to Binary Conversions 38 2.3.1 Converting Unsigned Whole Numbers 39 2.3.2 Converting

More information

Chapter 2. Data Representation in Computer Systems

Chapter 2. Data Representation in Computer Systems Chapter 2 Data Representation in Computer Systems Chapter 2 Objectives Understand the fundamentals of numerical data representation and manipulation in digital computers. Master the skill of converting

More information

Chapter 2. Data Representation in Computer Systems. Objectives (1 of 2) Objectives (2 of 2)

Chapter 2. Data Representation in Computer Systems. Objectives (1 of 2) Objectives (2 of 2) Chapter 2 Data Representation in Computer Systems Objectives (1 of 2) Understand the fundamentals of numerical data representation and manipulation in digital computers. Master the skill of converting

More information

Excerpt from: Stephen H. Unger, The Essence of Logic Circuits, Second Ed., Wiley, 1997

Excerpt from: Stephen H. Unger, The Essence of Logic Circuits, Second Ed., Wiley, 1997 Excerpt from: Stephen H. Unger, The Essence of Logic Circuits, Second Ed., Wiley, 1997 APPENDIX A.1 Number systems and codes Since ten-fingered humans are addicted to the decimal system, and since computers

More information

DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS

DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS C H A P T E R 6 DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS OUTLINE 6- Binary Addition 6-2 Representing Signed Numbers 6-3 Addition in the 2 s- Complement System 6-4 Subtraction in the 2 s- Complement

More information

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects: Numeral Systems -Numeral System -Positional systems -Decimal -Binary -Octal Subjects: Introduction A numeral system (or system of numeration) is a writing system for expressing numbers, that is a mathematical

More information

Chapter 1 Review of Number Systems

Chapter 1 Review of Number Systems 1.1 Introduction Chapter 1 Review of Number Systems Before the inception of digital computers, the only number system that was in common use is the decimal number system which has a total of 10 digits

More information

Level ISA3: Information Representation

Level ISA3: Information Representation Level ISA3: Information Representation 1 Information as electrical current At the lowest level, each storage unit in a computer s memory is equipped to contain either a high or low voltage signal Each

More information

Internal Data Representation

Internal Data Representation Appendices This part consists of seven appendices, which provide a wealth of reference material. Appendix A primarily discusses the number systems and their internal representation. Appendix B gives information

More information

Number System. Introduction. Decimal Numbers

Number System. Introduction. Decimal Numbers Number System Introduction Number systems provide the basis for all operations in information processing systems. In a number system the information is divided into a group of symbols; for example, 26

More information

COMPUTER ARITHMETIC (Part 1)

COMPUTER ARITHMETIC (Part 1) Eastern Mediterranean University School of Computing and Technology ITEC255 Computer Organization & Architecture COMPUTER ARITHMETIC (Part 1) Introduction The two principal concerns for computer arithmetic

More information

Bits, Words, and Integers

Bits, Words, and Integers Computer Science 52 Bits, Words, and Integers Spring Semester, 2017 In this document, we look at how bits are organized into meaningful data. In particular, we will see the details of how integers are

More information

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS Aleksandar Milenković The LaCASA Laboratory, ECE Department, The University of Alabama in Huntsville Email: milenka@uah.edu Web:

More information

Signed umbers. Sign/Magnitude otation

Signed umbers. Sign/Magnitude otation Signed umbers So far we have discussed unsigned number representations. In particular, we have looked at the binary number system and shorthand methods in representing binary codes. With m binary digits,

More information

Number Systems CHAPTER Positional Number Systems

Number Systems CHAPTER Positional Number Systems CHAPTER 2 Number Systems Inside computers, information is encoded as patterns of bits because it is easy to construct electronic circuits that exhibit the two alternative states, 0 and 1. The meaning of

More information

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS Aleksandar Milenković The LaCASA Laboratory, ECE Department, The University of Alabama in Huntsville Email: milenka@uah.edu Web:

More information

Topic Notes: Bits and Bytes and Numbers

Topic Notes: Bits and Bytes and Numbers Computer Science 220 Assembly Language & Comp Architecture Siena College Fall 2010 Topic Notes: Bits and Bytes and Numbers Binary Basics At least some of this will be review, but we will go over it for

More information

Math in MIPS. Subtracting a binary number from another binary number also bears an uncanny resemblance to the way it s done in decimal.

Math in MIPS. Subtracting a binary number from another binary number also bears an uncanny resemblance to the way it s done in decimal. Page < 1 > Math in MIPS Adding and Subtracting Numbers Adding two binary numbers together is very similar to the method used with decimal numbers, except simpler. When you add two binary numbers together,

More information

Chapter 3: part 3 Binary Subtraction

Chapter 3: part 3 Binary Subtraction Chapter 3: part 3 Binary Subtraction Iterative combinational circuits Binary adders Half and full adders Ripple carry and carry lookahead adders Binary subtraction Binary adder-subtractors Signed binary

More information

Chapter 10 - Computer Arithmetic

Chapter 10 - Computer Arithmetic Chapter 10 - Computer Arithmetic Luis Tarrataca luis.tarrataca@gmail.com CEFET-RJ L. Tarrataca Chapter 10 - Computer Arithmetic 1 / 126 1 Motivation 2 Arithmetic and Logic Unit 3 Integer representation

More information

Digital Logic Circuits Volume I Digital Number Systems

Digital Logic Circuits Volume I Digital Number Systems PDHonline Course E377 (5 PDH) Digital Logic Circuits Volume I Digital Number Systems Instructor: Lee Layton, P.E 2012 PDH Online PDH Center 5272 Meadow Estates Drive Fairfax, VA 22030-6658 Phone & Fax:

More information

D I G I T A L C I R C U I T S E E

D I G I T A L C I R C U I T S E E D I G I T A L C I R C U I T S E E Digital Circuits Basic Scope and Introduction This book covers theory solved examples and previous year gate question for following topics: Number system, Boolean algebra,

More information

COMPUTER ORGANIZATION AND ARCHITECTURE

COMPUTER ORGANIZATION AND ARCHITECTURE COMPUTER ORGANIZATION AND ARCHITECTURE For COMPUTER SCIENCE COMPUTER ORGANIZATION. SYLLABUS AND ARCHITECTURE Machine instructions and addressing modes, ALU and data-path, CPU control design, Memory interface,

More information

CHAPTER TWO. Data Representation ( M.MORRIS MANO COMPUTER SYSTEM ARCHITECTURE THIRD EDITION ) IN THIS CHAPTER

CHAPTER TWO. Data Representation ( M.MORRIS MANO COMPUTER SYSTEM ARCHITECTURE THIRD EDITION ) IN THIS CHAPTER 1 CHAPTER TWO Data Representation ( M.MORRIS MANO COMPUTER SYSTEM ARCHITECTURE THIRD EDITION ) IN THIS CHAPTER 2-1 Data Types 2-2 Complements 2-3 Fixed-Point Representation 2-4 Floating-Point Representation

More information

Lesson 1: THE DECIMAL SYSTEM

Lesson 1: THE DECIMAL SYSTEM Lesson 1: THE DECIMAL SYSTEM The word DECIMAL comes from a Latin word, which means "ten. The Decimal system uses the following ten digits to write a number: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Each time

More information

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University. Data Representation ti and Arithmetic for Computers Rui Wang, Assistant professor Dept. of Information and Communication Tongji University it Email: ruiwang@tongji.edu.cn Questions What do you know about

More information

UNIT - I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS

UNIT - I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS UNIT - I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS (09 periods) Computer Arithmetic: Data Representation, Fixed Point Representation, Floating Point Representation, Addition and

More information

Digital Systems and Binary Numbers

Digital Systems and Binary Numbers Digital Systems and Binary Numbers Prof. Wangrok Oh Dept. of Information Communications Eng. Chungnam National University Prof. Wangrok Oh(CNU) 1 / 51 Overview 1 Course Summary 2 Binary Numbers 3 Number-Base

More information

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. Numbers & Number Systems

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. Numbers & Number Systems SCHOOL OF ENGINEERING & BUILT ENVIRONMENT Mathematics Numbers & Number Systems Introduction Numbers and Their Properties Multiples and Factors The Division Algorithm Prime and Composite Numbers Prime Factors

More information

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers Computer Science 324 Computer Architecture Mount Holyoke College Fall 2007 Topic Notes: Bits and Bytes and Numbers Number Systems Much of this is review, given the 221 prerequisite Question: how high can

More information

Integers. N = sum (b i * 2 i ) where b i = 0 or 1. This is called unsigned binary representation. i = 31. i = 0

Integers. N = sum (b i * 2 i ) where b i = 0 or 1. This is called unsigned binary representation. i = 31. i = 0 Integers So far, we've seen how to convert numbers between bases. How do we represent particular kinds of data in a certain (32-bit) architecture? We will consider integers floating point characters What

More information

Kinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other

Kinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other Kinds Of Data CHAPTER 3 DATA REPRESENTATION Numbers Integers Unsigned Signed Reals Fixed-Point Floating-Point Binary-Coded Decimal Text ASCII Characters Strings Other Graphics Images Video Audio Numbers

More information

Data Representation 1

Data Representation 1 1 Data Representation Outline Binary Numbers Adding Binary Numbers Negative Integers Other Operations with Binary Numbers Floating Point Numbers Character Representation Image Representation Sound Representation

More information

CO212 Lecture 10: Arithmetic & Logical Unit

CO212 Lecture 10: Arithmetic & Logical Unit CO212 Lecture 10: Arithmetic & Logical Unit Shobhanjana Kalita, Dept. of CSE, Tezpur University Slides courtesy: Computer Architecture and Organization, 9 th Ed, W. Stallings Integer Representation For

More information

Data Representation Type of Data Representation Integers Bits Unsigned 2 s Comp Excess 7 Excess 8

Data Representation Type of Data Representation Integers Bits Unsigned 2 s Comp Excess 7 Excess 8 Data Representation At its most basic level, all digital information must reduce to 0s and 1s, which can be discussed as binary, octal, or hex data. There s no practical limit on how it can be interpreted

More information

MC1601 Computer Organization

MC1601 Computer Organization MC1601 Computer Organization Unit 1 : Digital Fundamentals Lesson1 : Number Systems and Conversions (KSB) (MCA) (2009-12/ODD) (2009-10/1 A&B) Coverage - Lesson1 Shows how various data types found in digital

More information

Representation of Non Negative Integers

Representation of Non Negative Integers Representation of Non Negative Integers In each of one s complement and two s complement arithmetic, no special steps are required to represent a non negative integer. All conversions to the complement

More information

Binary Addition & Subtraction. Unsigned and Sign & Magnitude numbers

Binary Addition & Subtraction. Unsigned and Sign & Magnitude numbers Binary Addition & Subtraction Unsigned and Sign & Magnitude numbers Addition and subtraction of unsigned or sign & magnitude binary numbers by hand proceeds exactly as with decimal numbers. (In fact this

More information

Divisibility Rules and Their Explanations

Divisibility Rules and Their Explanations Divisibility Rules and Their Explanations Increase Your Number Sense These divisibility rules apply to determining the divisibility of a positive integer (1, 2, 3, ) by another positive integer or 0 (although

More information

Topic Notes: Bits and Bytes and Numbers

Topic Notes: Bits and Bytes and Numbers Computer Science 220 Assembly Language & Comp Architecture Siena College Fall 2011 Topic Notes: Bits and Bytes and Numbers Binary Basics At least some of this will be review for most of you, but we start

More information

in this web service Cambridge University Press

in this web service Cambridge University Press 978-0-51-85748- - Switching and Finite Automata Theory, Third Edition Part 1 Preliminaries 978-0-51-85748- - Switching and Finite Automata Theory, Third Edition CHAPTER 1 Number systems and codes This

More information

Logic, Words, and Integers

Logic, Words, and Integers Computer Science 52 Logic, Words, and Integers 1 Words and Data The basic unit of information in a computer is the bit; it is simply a quantity that takes one of two values, 0 or 1. A sequence of k bits

More information

DIGITAL SYSTEM DESIGN

DIGITAL SYSTEM DESIGN DIGITAL SYSTEM DESIGN UNIT I: Introduction to Number Systems and Boolean Algebra Digital and Analog Basic Concepts, Some history of Digital Systems-Introduction to number systems, Binary numbers, Number

More information

Computer Organization

Computer Organization Computer Organization Register Transfer Logic Number System Department of Computer Science Missouri University of Science & Technology hurson@mst.edu 1 Decimal Numbers: Base 10 Digits: 0, 1, 2, 3, 4, 5,

More information

BINARY SYSTEM. Binary system is used in digital systems because it is:

BINARY SYSTEM. Binary system is used in digital systems because it is: CHAPTER 2 CHAPTER CONTENTS 2.1 Binary System 2.2 Binary Arithmetic Operation 2.3 Signed & Unsigned Numbers 2.4 Arithmetic Operations of Signed Numbers 2.5 Hexadecimal Number System 2.6 Octal Number System

More information

Chapter 5: Computer Arithmetic. In this chapter you will learn about:

Chapter 5: Computer Arithmetic. In this chapter you will learn about: Slide 1/29 Learning Objectives In this chapter you will learn about: Reasons for using binary instead of decimal numbers Basic arithmetic operations using binary numbers Addition (+) Subtraction (-) Multiplication

More information

(+A) + ( B) + (A B) (B A) + (A B) ( A) + (+ B) (A B) + (B A) + (A B) (+ A) (+ B) + (A - B) (B A) + (A B) ( A) ( B) (A B) + (B A) + (A B)

(+A) + ( B) + (A B) (B A) + (A B) ( A) + (+ B) (A B) + (B A) + (A B) (+ A) (+ B) + (A - B) (B A) + (A B) ( A) ( B) (A B) + (B A) + (A B) COMPUTER ARITHMETIC 1. Addition and Subtraction of Unsigned Numbers The direct method of subtraction taught in elementary schools uses the borrowconcept. In this method we borrow a 1 from a higher significant

More information

Logic Circuits I ECE 1411 Thursday 4:45pm-7:20pm. Nathan Pihlstrom.

Logic Circuits I ECE 1411 Thursday 4:45pm-7:20pm. Nathan Pihlstrom. Logic Circuits I ECE 1411 Thursday 4:45pm-7:20pm Nathan Pihlstrom www.uccs.edu/~npihlstr My Background B.S.E.E. from Colorado State University M.S.E.E. from Colorado State University M.B.A. from UCCS Ford

More information

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes Digital Fundamentals CHAPTER 2 Number Systems, Operations, and Codes Decimal Numbers The decimal number system has ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 The decimal numbering system has a base of

More information

NUMBER SYSTEMS AND CODES

NUMBER SYSTEMS AND CODES C H A P T E R 69 Learning Objectives Number Systems The Decimal Number System Binary Number System Binary to Decimal Conversion Binary Fractions Double-Dadd Method Decimal to Binary Conversion Shifting

More information

Number representations

Number representations Number representations Number bases Three number bases are of interest: Binary, Octal and Hexadecimal. We look briefly at conversions among them and between each of them and decimal. Binary Base-two, or

More information

Learning Objectives. Binary over Decimal. In this chapter you will learn about:

Learning Objectives. Binary over Decimal. In this chapter you will learn about: Ref Page Slide 1/29 Learning Objectives In this chapter you will learn about: Reasons for using binary instead of decimal numbers Basic arithmetic operations using binary numbers Addition (+) Subtraction

More information

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall Notes - Unit 4. hundreds.

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall Notes - Unit 4. hundreds. ECE-78: Digital Logic Design Fall 6 UNSIGNED INTEGER NUMBERS Notes - Unit 4 DECIMAL NUMBER SYSTEM A decimal digit can take values from to 9: Digit-by-digit representation of a positive integer number (powers

More information

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700: Digital Logic Design Winter Notes - Unit 4. hundreds.

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700: Digital Logic Design Winter Notes - Unit 4. hundreds. UNSIGNED INTEGER NUMBERS Notes - Unit 4 DECIMAL NUMBER SYSTEM A decimal digit can take values from to 9: Digit-by-digit representation of a positive integer number (powers of ): DIGIT 3 4 5 6 7 8 9 Number:

More information

Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers

Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers Real Numbers We have been studying integer arithmetic up to this point. We have discovered that a standard computer can represent a finite subset of the infinite set of integers. The range is determined

More information

CHW 261: Logic Design

CHW 261: Logic Design CHW 261: Logic Design Instructors: Prof. Hala Zayed Dr. Ahmed Shalaby http://www.bu.edu.eg/staff/halazayed14 http://bu.edu.eg/staff/ahmedshalaby14# Slide 1 Slide 2 Slide 3 Digital Fundamentals CHAPTER

More information

Memory Addressing, Binary, and Hexadecimal Review

Memory Addressing, Binary, and Hexadecimal Review C++ By A EXAMPLE Memory Addressing, Binary, and Hexadecimal Review You do not have to understand the concepts in this appendix to become well-versed in C++. You can master C++, however, only if you spend

More information

Binary Addition. Add the binary numbers and and show the equivalent decimal addition.

Binary Addition. Add the binary numbers and and show the equivalent decimal addition. Binary Addition The rules for binary addition are 0 + 0 = 0 Sum = 0, carry = 0 0 + 1 = 0 Sum = 1, carry = 0 1 + 0 = 0 Sum = 1, carry = 0 1 + 1 = 10 Sum = 0, carry = 1 When an input carry = 1 due to a previous

More information

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude Chapter 2 Positional number systems A positional number system represents numeric values as sequences of one or more digits. Each digit in the representation is weighted according to its position in the

More information

Learning the Binary System

Learning the Binary System Learning the Binary System www.brainlubeonline.com/counting_on_binary/ Formated to L A TEX: /25/22 Abstract This is a document on the base-2 abstract numerical system, or Binary system. This is a VERY

More information

Chapter 4 Arithmetic Functions

Chapter 4 Arithmetic Functions Logic and Computer Design Fundamentals Chapter 4 Arithmetic Functions Charles Kime & Thomas Kaminski 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Overview Iterative combinational

More information

carry in carry 1101 carry carry

carry in carry 1101 carry carry Chapter Binary arithmetic Arithmetic is the process of applying a mathematical operator (such as negation or addition) to one or more operands (the values being operated upon). Binary arithmetic works

More information

Numbering systems. Dr Abu Arqoub

Numbering systems. Dr Abu Arqoub Numbering systems The decimal numbering system is widely used, because the people Accustomed (معتاد) to use the hand fingers in their counting. But with the development of the computer science another

More information

Chapter 3 Data Representation

Chapter 3 Data Representation Chapter 3 Data Representation The focus of this chapter is the representation of data in a digital computer. We begin with a review of several number systems (decimal, binary, octal, and hexadecimal) and

More information

COMP Overview of Tutorial #2

COMP Overview of Tutorial #2 COMP 1402 Winter 2008 Tutorial #2 Overview of Tutorial #2 Number representation basics Binary conversions Octal conversions Hexadecimal conversions Signed numbers (signed magnitude, one s and two s complement,

More information

Divide: Paper & Pencil

Divide: Paper & Pencil Divide: Paper & Pencil 1001 Quotient Divisor 1000 1001010 Dividend -1000 10 101 1010 1000 10 Remainder See how big a number can be subtracted, creating quotient bit on each step Binary => 1 * divisor or

More information

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1 IT 1204 Section 2.0 Data Representation and Arithmetic 2009, University of Colombo School of Computing 1 What is Analog and Digital The interpretation of an analog signal would correspond to a signal whose

More information

Basic Arithmetic Operations

Basic Arithmetic Operations Basic Arithmetic Operations Learning Outcome When you complete this module you will be able to: Perform basic arithmetic operations without the use of a calculator. Learning Objectives Here is what you

More information

Number Systems and Computer Arithmetic

Number Systems and Computer Arithmetic Number Systems and Computer Arithmetic Counting to four billion two fingers at a time What do all those bits mean now? bits (011011011100010...01) instruction R-format I-format... integer data number text

More information

Module 1: Information Representation I -- Number Systems

Module 1: Information Representation I -- Number Systems Unit 1: Computer Systems, pages 1 of 7 - Department of Computer and Mathematical Sciences CS 1305 Intro to Computer Technology 1 Module 1: Information Representation I -- Number Systems Objectives: Learn

More information

Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers

Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers Real Numbers We have been studying integer arithmetic up to this point. We have discovered that a standard computer can represent a finite subset of the infinite set of integers. The range is determined

More information

COMPUTER ARCHITECTURE AND ORGANIZATION. Operation Add Magnitudes Subtract Magnitudes (+A) + ( B) + (A B) (B A) + (A B)

COMPUTER ARCHITECTURE AND ORGANIZATION. Operation Add Magnitudes Subtract Magnitudes (+A) + ( B) + (A B) (B A) + (A B) Computer Arithmetic Data is manipulated by using the arithmetic instructions in digital computers. Data is manipulated to produce results necessary to give solution for the computation problems. The Addition,

More information

COE 202: Digital Logic Design Number Systems Part 2. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

COE 202: Digital Logic Design Number Systems Part 2. Dr. Ahmad Almulhem   ahmadsm AT kfupm Phone: Office: COE 0: Digital Logic Design Number Systems Part Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: -34 Objectives Arithmetic operations: Binary number system Other number systems Base Conversion

More information

Computer Arithmetic. In this article we look at the way in which numbers are represented in binary form and manipulated in a computer.

Computer Arithmetic. In this article we look at the way in which numbers are represented in binary form and manipulated in a computer. Computer Arithmetic In this article we look at the way in which numbers are represented in binary form and manipulated in a computer. Numbers have a long history. In Europe up to about 400 numbers were

More information

Chapter 4 Section 2 Operations on Decimals

Chapter 4 Section 2 Operations on Decimals Chapter 4 Section 2 Operations on Decimals Addition and subtraction of decimals To add decimals, write the numbers so that the decimal points are on a vertical line. Add as you would with whole numbers.

More information

Properties and Definitions

Properties and Definitions Section 0.1 Contents: Operations Defined Multiplication as an Abbreviation Visualizing Multiplication Commutative Properties Parentheses Associative Properties Identities Zero Product Answers to Exercises

More information

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning 4 Operations On Data 4.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List the three categories of operations performed on data.

More information

Number Systems. Both numbers are positive

Number Systems. Both numbers are positive Number Systems Range of Numbers and Overflow When arithmetic operation such as Addition, Subtraction, Multiplication and Division are performed on numbers the results generated may exceed the range of

More information

UNIT 2 NUMBER SYSTEM AND PROGRAMMING LANGUAGES

UNIT 2 NUMBER SYSTEM AND PROGRAMMING LANGUAGES UNIT 2 NUMBER SYSTEM AND PROGRAMMING LANGUAGES Structure 2.0 Introduction 2.1 Unit Objectives 2.2 Number Systems 2.3 Bits and Bytes 2.4 Binary Number System 2.5 Decimal Number System 2.6 Octal Number System

More information

Chapter 4. Operations on Data

Chapter 4. Operations on Data Chapter 4 Operations on Data 1 OBJECTIVES After reading this chapter, the reader should be able to: List the three categories of operations performed on data. Perform unary and binary logic operations

More information

Excerpt from "Art of Problem Solving Volume 1: the Basics" 2014 AoPS Inc.

Excerpt from Art of Problem Solving Volume 1: the Basics 2014 AoPS Inc. Chapter 5 Using the Integers In spite of their being a rather restricted class of numbers, the integers have a lot of interesting properties and uses. Math which involves the properties of integers is

More information

Logic and Computer Design Fundamentals. Chapter 1 Digital Computers and Information

Logic and Computer Design Fundamentals. Chapter 1 Digital Computers and Information Logic and Computer Design Fundamentals Chapter 1 Digital Computers and Information Overview Digital Systems and Computer Systems Information Representation Number Systems [binary, octal and hexadecimal]

More information

CS 101: Computer Programming and Utilization

CS 101: Computer Programming and Utilization CS 101: Computer Programming and Utilization Jul-Nov 2017 Umesh Bellur (cs101@cse.iitb.ac.in) Lecture 3: Number Representa.ons Representing Numbers Digital Circuits can store and manipulate 0 s and 1 s.

More information

Chapter 3 Arithmetic for Computers (Part 2)

Chapter 3 Arithmetic for Computers (Part 2) Department of Electr rical Eng ineering, Chapter 3 Arithmetic for Computers (Part 2) 王振傑 (Chen-Chieh Wang) ccwang@mail.ee.ncku.edu.tw ncku edu Depar rtment of Electr rical Eng ineering, Feng-Chia Unive

More information

THE LOGIC OF COMPOUND STATEMENTS

THE LOGIC OF COMPOUND STATEMENTS CHAPTER 2 THE LOGIC OF COMPOUND STATEMENTS Copyright Cengage Learning. All rights reserved. SECTION 2.5 Application: Number Systems and Circuits for Addition Copyright Cengage Learning. All rights reserved.

More information

Lecture 8: Addition, Multiplication & Division

Lecture 8: Addition, Multiplication & Division Lecture 8: Addition, Multiplication & Division Today s topics: Signed/Unsigned Addition Multiplication Division 1 Signed / Unsigned The hardware recognizes two formats: unsigned (corresponding to the C

More information

CS101 Lecture 04: Binary Arithmetic

CS101 Lecture 04: Binary Arithmetic CS101 Lecture 04: Binary Arithmetic Binary Number Addition Two s complement encoding Briefly: real number representation Aaron Stevens (azs@bu.edu) 25 January 2013 What You ll Learn Today Counting in binary

More information

Lecture 2: Number Systems

Lecture 2: Number Systems Lecture 2: Number Systems Syed M. Mahmud, Ph.D ECE Department Wayne State University Original Source: Prof. Russell Tessier of University of Massachusetts Aby George of Wayne State University Contents

More information

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010 Contents Number systems and conversion Binary arithmetic Representation of negative numbers Addition of two s complement numbers Addition of one s complement numbers Binary s Readings Unit.~. UNIT NUMBER

More information

Binary Systems and Codes

Binary Systems and Codes 1010101010101010101010101010101010101010101010101010101010101010101010101010101010 1010101010101010101010101010101010101010101010101010101010101010101010101010101010 1010101010101010101010101010101010101010101010101010101010101010101010101010101010

More information

Chapter 5: Computer Arithmetic

Chapter 5: Computer Arithmetic Slide 1/29 Learning Objectives Computer Fundamentals: Pradeep K. Sinha & Priti Sinha In this chapter you will learn about: Reasons for using binary instead of decimal numbers Basic arithmetic operations

More information

Number Systems. Course No: E Credit: 4 PDH. Jeffrey Cwalinski, P.E.

Number Systems. Course No: E Credit: 4 PDH. Jeffrey Cwalinski, P.E. Number Systems Course No: E04-029 Credit: 4 PDH Jeffrey Cwalinski, P.E. Continuing Education and Development, Inc. 9 Greyridge Farm Court Stony Point, NY 10980 P: (877) 322-5800 F: (877) 322-4774 info@cedengineering.com

More information