CHAPTER 3 Number System and Codes


 Candice Cook
 2 years ago
 Views:
Transcription
1 CHAPTER 3 Number System and Codes 3.1 Introduction On hearing the word number, we immediately think of familiar decimal number system with its 10 digits; 0,1, 2,3,4,5,6, 7, 8 and 9. these numbers are called Arabic. Our present number system provides modern mathematicians and scientists with a great advantage over those of previous civilizations and is an important factor in our advancement. Since hands are the most convenient tools nature has provided human being have always tended to use them in counting. So the decimal number system followed naturally from this usage. The key feature that distinguishes one number system from another is the number system's base or radix. This base indicates the number of digits that will be used. To determine the quantity that the number represents, it is necessary to multiply each digit by an integer power of r, and then form the sum of all weighed digits. It is possible to use any whole number greater than one as a base in building a numeration system. There are four systems of arithmetic which are often used in digital system. These are: Decimal Binary Hexadecimal Octal 3.2 Decimal and Binary Numbers The decimal system of counting and keeping track of items was first created by Hindu mathematicians in India in A.D Since it involved the use of fingers and thumbs, it was natural that this system would have 10 digits. The system found its way to all the Arab countries by A.D. 800, where it was named the Arabic number system, and from there it was eventually adopted by nearly all the European countries by A.D. 1200, where it was called the decimal number system. The key feature that distinguishes one number system from another is the number system's base or radix. This base indicates the number of digits that will be used. The decimal number system, for example, is a base 10 number system which means that it uses 10 digits (0 to 9) to communicate information about an amount. A subscript is something included after a number when different number systems are being used to indicate the base of the number. For example would represent a number in base 7 (using the digits 0 to 6) number system. Example and are two numbers which contain the same digits but which are written using different bases. The first number we recognize as one thousand one hundred in the decimal (base 10) number system. The second number is a number in the base 2 number system called the binary number system. We shall look at the binary number system later.
2 26 CHAPTER 3 Decimal Numbers Written Using Positional Notation Consider the decimal number Each digit in this number has a positional value. The last digit 7 is the units digit. Its positional value is 7 x 1. The 3 is the tens digit. Its positional value is 3 x 10. The 2 is the hundreds digit. Its positional value is 2 x 100. The 5 is the thousands digits. Its positional value is 5 x We may write then that: = 5 x x x x 1 using positional value notation. The position, then, of each digit of a decimal number determines the weight of that digit. The digit which contributes the least weight is called the LSD (least significant digit) and the digit which contributes the most weight is called the MSD. In our example, 7 is the LSD and 5 is the MSD. In chart form, we can write: Positional Name thousands hundreds tens units Positional Weight Value in Positional Notation Problem Write using positional value notation x x x x The Binary Number System Counting in the Decimal (Base 10) Number System You know how to count in the decimal system: Start Counting: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. When you reach 9, you run out of units digits to use. So you reset the units digit to 0 and carry 1 to the tens column. Then you can keep counting. Continue Counting: 10, 11, 12,..., 19. When you reach 19, you must reset the units digit to 0 again and carry 1 over to the tens column which when added to the one there gives 2 and you may continue counting. Count some More: 20, 21, 22, 23,..., all the way to 98, 99 When you reach 99, you have to reset the units column to 0 and carry 1 which will cause the tens column to have to be reset to 0 and 1 carried over to the hundreds column. Continue Counting: 100, 101, 102, and... well, Counting in the Binary (Base 2) Number System
3 Number System and Codes 27 The binary system is a base two system. The only digits that can be used are 0 and 1. Let's start counting: Start counting: 0, 1 We have used both 0 and 1 for the units digit. That's it for the units digit. The units digit must now be reset to 0 and a 1 carried to the next digit. Continue counting: 10, 11 Now the units digit has to be reset again to 0 and a 1 carried to the left. This will cause the second digit from the right to have to be reset making the third digit from the left now 1. Keep Counting: The next 8 binary numbers are: 100, 101, 110, 111, 1000, 1001,1010, 1011 Keep your finger off the scroll bar and see if you can list the next four binary numbers, then check the table below: The first 17 decimal integers and their binary equivalents: Decimal Binary Decimal Binary Positional Notation in the Binary Number System We saw that each digit in a decimal number carries its own weight. The rightmost digit in a decimal number is the units digit; the weight of each digit increases by a factor of 10 as one moves to the left. Computers use binary number notation extensively. In computers, each digit in a binary number is called a bit. Eight bits make up one byte. The rightmost digit in a binary number is the units digit. The weight of each digit increases by a factor of 2 as one moves from right to left in a binary number. The following table gives the positional weight of each bit in the byte and uses the positional weight of each column to express the number in decimal form: Positional Weight Value Number Positional Notation = 1x x64 + 0x32 + 0x16 + 0x8 + 1x4 + 0x2 + 1x1 = 197 Note the LSD in is the right most digit which is 1 and the MSD is the left most digit which is 1. Problems Convert to decimal numbers: a) b)
4 28 CHAPTER Converting Decimal Numbers to Binary Numbers Method A  Write the Number as a Sum of Powers of 2 Any decimal number between 1 and 8 can be quickly converted into a binary number between 0 2 and by writing the number as the sum of powers of 2. Example Convert to binary by writing 11 as a sum of powers of 2 Solution: The powers of 2 are: 1, 2, 4, 8, 16, 32 etc. Powers of = = Any decimal number between 8 and 128 can also be converted to binary reasonably easily using this method: Example Convert to binary: Powers of = = Method B  Use Repeated Division To convert a decimal number to binary, we can also use repeated division and note the remainder after each division. Example Convert to binary converted to a binary number: Division Remainder 1 LSD MSD
5 Number System and Codes 29 Note that the first remainder gives the LSD and the last remainder the MSD. Then, = Check: = = 837 Problems Convert to binary numbers using Method A expressing the number as a sum of powers of 2: a) b) Convert to binary number using Method B repeated division by 2 a) b) Binary Numbers and Computers Binary is the language of computers. Everything you type, input, output, send, retrieve, draw or paint is, in the end, converted to the computer's native language, binary. Each byte of memory consists of 8 bits. Each bit is a binary 1 or 0. When you type the letter A, the decimal number 65 is stored in the computer's memory in a byte of memory in binary form as The table below gives ASCII (American Standard Code for Information Interchange) codes for the letters A through I. Letter Decimal Representation 7 bit Binary Representation A B C D E F G H I Suppose your IBM ThinkPad has 9.76 gigabytes of memory. A gigabyte is roughly 1 billion bytes, so you could store roughly 10 billion letters in your computer's memory. That's 80 billion 0's and 1's. A page of word processing contains about characters. That means you could store 3.5 million pages of information in your computer's memory, again all in 0's and 1's. For Discussion: In a computer, registers are used to store information. An 8bit register is one which can hold up to 8 digits. Many computers work with 8bit registers or multiples of 8bit registers (that is 16, 24, 32, etc). a) How many different binary representations can be stored in an 8bit register? b) Repeat a) for a 16 bit register c) Generalize to come up with a rule: If you have an xbit register, how many different binary representations can be stored in the register?
6 30 CHAPTER 3 d) What is the smallest and largest decimal number that can be stored in an 8bit register? in a 16bit register? Problem Assignment Give the next three binary numbers after the following binary numbers: a) 10 2 b) c) d) e) Convert the following binary numbers to numbers in base 10: a) b) c) d) Use a sum to convert the following decimal numbers to binary numbers: a) b) c) d) Convert the following decimal numbers to binary using division: a) b) What are the full names for the acronyms LSD sand MSD. Answers Problem x x x 1 Problems a) 8 b) 13 Problems a) b) a) b) Problem Assignment a) 10, 11, 100, 101 b) 100, 101, 110, 111 c) 110, 111, 1000, 1001 d) 1010, 1011, 1100, 1101 e) 1111, , , a) 11 b) 9 c) 13 d) a) b) c) d) a) b) LSD =least significant digit MSD = most significant digit 3.4 Hexadecimal Numbers In the previous section we looked at the decimal (base 10) and binary (base 2) number systems. In this section we look at the hexadecimal (base 16) number system. Both binary and hexadecimal numbers are used in computing. The decimal (base 10) number system uses 10 digits: 0, 1, 2, 3,..., 9 The binary (base 2) number system uses 2 digits: 0, 1 The hexadecimal (base 16) number system uses 16 digits: 0, 1, 2, 3,..., 9, A, B, C, D, E and F. The first 10 whole numbers in the hexadecimal system are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. Once we reach 9, we run out of ordinary digits, since there are only ten digits available. Hexadecimal uses the following convention: The number = A 16, = B 16, = C 16, = D 16, = E 16, = F 16. So the first sixteen whole numbers in the hexadecimal number system are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F. After we reach the number F there are no more digits left to use for the units digit. The next number is 10. Continuing to count we have: 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1A, 1B, 1C, 1D, 1E, 1F, 20,..., 2F, 30,..., 3F
7 Number System and Codes 31 Problems Can you count in hexadecimal? a) 45, 46, 47, 48,... b) 116, 117, 118,.. c) 3A7, 3A8, 3A9,... d) AB, AC, AD,... e) A997, A998, A999,... Give the next five numbers in each of these sequences: Positional Weights of Digits in the Hexadecimal System  Conversions Hex to Decimal and Decimal to Hex The hexadecimal column weights are: Example The hexadecimal number 13A7 16 written using positional notation is: 13A7 16 = 1 x x A x x 16 0 To convert a hexadecimal number to a decimal number, we evaluate the expression for the number using positional notation. Example The decimal value of 13A7 16 can be determined by evaluating the positional notation expression. 13A7 16 = 1 x x A x x 16 0 = 1 x x x x 1 = Problem Show that 573A 16 = Problems Convert the following hexadecimal numbers to decimal numbers: a) 8C5 16 b) AEF Converting Decimal Numbers to Hexadecimal Numbers As we did for converting a decimal number to a binary number, to convert a decimal number to hexadecimal number, we shall use repeated division and note the remainder after each division. There were only two possible remainders 0 and 1 when converting to binary. In converting to base 16, however, there are 16 possible remainders is converted to hexadecimal in the table below. This method is called the calculator method converted to a hexadecimal number: Division Remainder x 16 = 11 B LSD x 16 = 11 B x 16 = 15 F 1 < 16 end the algorithm 1 1 MSD Therefore, = 1FBB 16.
8 32 CHAPTER 3 The conversion can be checked by converting 1FBB 16 back to a decimal number. 1FBB = 1 x x x = Problem Convert into a hexadecimal number and check Converting Binary Numbers to Hexadecimal Numbers As they increase in magnitude, binary numbers quickly become unwieldy for those involved with their use in computers. The five digit decimal number in binary is It can be seen that a 0 or 1 can easily be dropped or added. It is easy to convert binary numbers to their equivalent hexadecimal form. For this reason, binary numbers when used with computers are often written in hexadecimal form. Example To convert a binary number such as above to hexadecimal, convert each group of 4 digits beginning with the LSD into hex. Binary Number Grouped into 4's Equivalent Hex Digit It follows then that the = Problem Show that = 2B Converting Hexadecimal Numbers to Binary Numbers To convert a hexadecimal number to a binary number, we reverse the above procedure. Example To convert the hexadecimal number 9F2 16 to binary, each hex digit is converted into binary form. 9F2 16 = Problems a) Convert hexadecimal 2BF9 to its binary equivalent. b) Convert binary to its hexadecimal equivalent Hexadecimal Numbers in Computing Although numbers in a computer are stored in binary form, the hex representation is usually used. The hex representation of a byte requires only two digits and the hex representation of two bytes (a word) requires only 4 digits in hex compared to 16 digits in binary. The table below gives the decimal and hex representation for all the ASCII codes from 0 to Problem Assignment What is the base of each of the following number systems: a) decimal number system b) binary number system c) hexadecimal number system? 2. What are the decimal and hexadecimal equivalents of ? 3. Convert to its hexadecimal equivalent. 4. What are the binary and hexadecimal equivalents of 43 10?
9 Number System and Codes 33 Answers Problems a) 49, 4A, 4B, 4C, 4D,... b) 119, 11A, 11B, 11C, 11D.. c) 3AA, 3AB, 3AC, 3AD, 3AE.. d) AE, AF, B0, B1, B2. e) A99A, A99B, A99C, A99D, A99E... Problems a) 8C5 16 = b) AEF1 16 = Problem = Problems a) 2BF9 16 = b) = CE1 16 Problem Assignment a) 10 b) 2 c) , 1D BF7A , 2B 16
10 34 CHAPTER Binary Arithmetic Binary Addition When two single digit decimal numbers are added, there are many possible sums: Examples: = 9, = 15, = 12. When two decimal numbers containing more than single digits are added, the method of carrying digits from one column to another is used. Example: To arrive at an answer of 152, one adds the 7 and 5 to get 12. The 1 from the 12 is carried to the tens column and = 15. We saw in an earlier section that when you use the binary number system, only the digits 0 and 1 are used. Following are some examples of adding binary digits: First Addition: Add two zeroes: = 0 Second Addition: Add a 0 and a 1: = 1 or = 1 Third Addition: Add two 1's: = 10 Fourth Addition: Add two 1's and a 1 which was carried over from the previous column: = 11 Example Add these binary numbers: [We follow the usual convention of leaving a space between groups of 4 binary digits] If this addition is analyzed column by column: Column 5 Column 4 Column 3 Column 2 Column 1 First Number Second Number Sum = 1 1 (include the 1 carried from the previous column to the right) = 10 1 is carried left to the next column = = 1
11 Number System and Codes Problem Assignment Perform the following additions of binary numbers: a) 1 +1 b) 1 +0 c) d) e) f) g) h) i) j) Add: (check by converting to decimal) 3. Add +18 and +12 in binary and convert back to decimal. 4. Add +30 and +34 in binary and convert back to decimal. Answers 1. a) 10 b) 1 c) 11 d) 100 e) 101 f) 110 g) 1001 h) 1011 i) j) = = Storing Integers in Binary  SignMagnitude Representation As we have seen in previous sections, information is stored in computers in binary form. Traditionally information is stored in bytes consisting of 8 bits or in words consisting of 2 bytes (16 bits) or double words consisting of 4 bytes or 32 bits. The meaning of a "word" is computers can vary from machine to machine. In larger mainframes a word is defined as 64 bits. Another term that is used is nibble (or nibble). A nibble is half a byte or four bits. Example For example, the letter A is stored in a computer in ASCII code form as the number 65 which stored in a byte in binary is Example If a byte contains the bits , the decimal representation is = 123. The character having ASCII code 123 is the left bracket "(". We also discussed earlier than when working with binary numbers, people involved with computers often use hex notation rather than binary notation. Problem Write and in hexadecimal form.
12 36 CHAPTER 3 Labeling of Bits In Example above we indicated that the ASCII code for the letter A is the decimal number 65. In binary, this number is The bits in a byte are labeled from 0 (the least significant bit) to 7 (the most significant bit) Bit Number Binary Representation of the letter A MSB Current computers also use 16 bit, 32 bit and even 64 bit "words" to store information. However, at this point we shall restrict ourselves to dealing with looking at information stored in 4 bits (a nibble) or in bytes Representing Integers in Binary ASCII codes are pure or true binary numbers. By that we mean there is no positive or negative sign attached to these numbers. We are now going to look at representing integers in binary. For example, points on a grid are represented using ordered pairs. You may recall from high school math that the ordered pair P(4,2) represents a point in the second quadrant of an xyplane. To store this ordered pair would require the storage of the negative integer 4. In other example, we want to add +17 and 11 on a computer to yield the result +6. The integers +17 and 11 would be stored somewhere in the computer's memory. To be added, they would both have to be brought into the central processing unit (CPU) of the computer and put into registers where they would be added. Here are some of the challenges we face when we move to representing integers in binary: 1. Integers can be positive or negative. Any representation of an integer must have the sign as part of the representation of the number. 2. Each integer should have a unique representation. 3. We added two binary numbers in the last section. Once we represent positive and negative integers in binary form, we want to be able to add and subtract them. 4. The addition and subtraction should be as efficient as possible. We would like to perform these operations using the smallest number of circuits possible. LSB SignMagnitude Binary Number System The sign and magnitude number system is a simple binary code system used to represent positive and negative integers. In this system, the first bit (the MSB) in a binary representation is a sign bit (0 for positive and 1 for negative) followed by the magnitude bits. Example If information is stored in nibbles using signmagnitude notation, 0101 represents a positive integer because the MSB is 0 while 1010 represents a negative integer because the MSB is 1. In particular situations, the number of bits is specified and if not all bits are used, they are filled with zeroes.
13 Number System and Codes Representation of Positive Integers using SignMagnitude Notation Example When a 4bit signmagnitude convention for representing numbers is used, the number 0101 represents the number +5. The most significant bit (MSB) is the first bit which is a 0. The 0 indicates the number is positive. The remaining 3 bits represent the magnitude of the number. The decimal value of binary 101 is = 5. Therefore, 0101, using a 4bit signmagnitude convention is the integer +5. The following table lists all the positive numbers that can be represented using 4 bits: Decimal Number Binary Representation Using 4 bit signmagnitude notation Problem How many positive binary numbers can be represented in a byte using the signmagnitude notation? Representation of Negative Integers using SignMagnitude Notation Example When an 8bit signmagnitude convention for representing numbers is used, the number represents the negative integer 55. The first bit, the MSB, is 1 indicating the integer is negative. The next 7 bits represent the magnitude of the integer. Binary has decimal value = 55. Example Store 5 using a 4bit signmagnitude convention. Solution: 5 is stored as 1101 The first digit, the MSB, is 1 because the number is negative. The last three digits 101 is 5 in binary. 3.8 Problem Assignment List all of the negative integers that can be stored in a nibble (4bits) in binary using the signmagnitude notation. 2. How many different negative integers can be stored in a byte using the signmagnitude notation?
14 38 CHAPTER 3 3. What are the decimal values of these bytes storing signmagnitude integers? Write '93' in signmagnitude representation, using an 8bit register. 5. What is the largest positive number which can be represented in an 8bit register, using the signmagnitude method of representation? 6. What is the largest negative number which can be represented in an 8bit register, using the signmagnitude method of representation? 7. Give the range of possible numbers which can be represented in a 16bit register, using the signmagnitude method. 8. A drawback to the signmagnitude notation is that there are two representations of the integer 0. What are they? 9. We now have two ways of representing integers in binary: true binary form and signmagnitude notation. Complete the following table: A byte contains the following bits a) b) c) d) What integer does this byte represent if the bits represent an integer in true binary form? What integer does this byte represent if the bits represent an integer using signmagnitude notation? 10. Complete the following table: A decimal number is to be stored in a byte. a) +11 Give the representation if true binary form is used. Give the representation if the signmagnitude form is used? b) +147 c) 17 d) 57 As indicated in the above problems, a drawback to using the signmagnitude notation to represent integers is that there are two representations of the integer 0. In computers, equality of numbers is usually determined by checking bit by bit for equality. There would have to be a special algorithm for equality just to deal with the integer 0. The signmagnitude notation is used to store integers in computers. For example, signmagnitude notation would be appropriate to store the components of the ordered pair ( 5,7) if this ordered pair represents a point on a plane. However, there is another way of storing positive and negative integers that proves to be a representation that makes addition and subtraction of integers easy and efficient. This notation will be discussed in the next section.
15 Number System and Codes 39 Answers Problem B Problem If 0 is counted as a positive integer, the numbers range from to which is 0 to 127 which is 128 different integers Problem Assignment Binary Decimal Value if 0 is included ( ) ( ) 7. from to and A byte contains the following bits What integer does this byte represent if the bits represent an integer in pure binary form? a) What integer does this byte represent if the bits represent an integer using signmagnitude notation? b) c) d) A decimal number is to be stored in a byte. Give the representation if true binary form is used. Give the representation if the signmagnitude form is used? a) b) cannot be represented using a byte c) 17 d) 57 no true binary representation in computers  must use a sign bit no true binary representation in computers
16 40 CHAPTER One's Complement Notation We saw in previous sections that there are different ways of storing binary numbers in computers. A number, such as decimal 84, may be stored in true binary form in a byte as When this same number 84 is thought of as the integer +84, then the sign must be stored as part of the representation. The convention we used to store this positive integer in a byte was the signmagnitude notation. The signmagnitude representation of +84 in a byte, , is the same as the representation of 84 in true binary form in a byte. Although the representations are the same, the MSB of 0, which is bit 7 has a different interpretation in each notation. When the number 84 is stored without a sign in true binary form as in a byte, the MSB of 0 is part of the magnitude of the number. When the positive integer +84 is stored in a byte, using signmagnitude notation, as , the MSB of 0 indicates that the integer is positive. The magnitude of the integer is determined from the remaining bits 0 to 6. We have also stored negative integers, such as 47, in a byte using signmagnitude notation. Can you explain why the signmagnitude representation of 47 stored in a byte using signmagnitude notation is ? We also saw that there are two representations of the integer 0 using signmagnitude notation. Using bytes, these representations are and We also commented that it is not easy to perform both addition and subtraction electronically using integers stored in bytes in either true binary or signmagnitude notation. Therefore, in this section we look at another way of storing integers in computers. This method is called the 1's complement notation. We introduce this notation in this section so that in the next section we can determine the 2's complement of an integer and from there go on to add and subtract integers The 1's Complement in Binary of a Positive Integer The 1's complement representation in binary of a positive integer is no different from the signmagnitude representation of that integer. Example Using a byte, the 1's complement in binary of +84 is Problems Using a byte, what is the 1's complement in binary of +73? 2. Using a byte, what is the 1's complement in binary of +23?
17 Number System and Codes The 1's Complement in Binary of a Negative Integer The determination of the 1's complement in binary of a negative integer is not quite so straightforward as calculating the 1's complement in binary of a positive integer. The formal way to determine the 1's complement in binary of a negative integer uses the following rule: Rule: The 1's complement in binary of a negative integer is obtained by subtracting its magnitude from 2 n 1 where n is the number of bits used to store the integer in binary. This is best illustrated using an example. From this point on we replace 1's complement in binary with 1's complement. We assume that we are working in binary. Example Store the integer 36 in a byte in 1's complement form. Step 1: = [convert the magnitude of the integer to binary] Step 2: A byte contains 8 bits. Therefore, subtract from = 255. In binary 255 is This determination of the 1's complement of a negative integer would seem to be awkward and one would imagine that the computer circuitry needed to accomplish finding the 1's complement would be complex. However, we note the following: Using a byte, the 1's complement of +36 is Using a byte, the 1's complement of 36 is If these representations are compared bit by bit, one can see that corresponding bits are inverted. There is in fact, then, an easy way to determine the 1's complement of a negative integer. Determine the 1's complement of the corresponding positive integer and invert all bits. Example Using a byte, find the 1's complement of 57. Solution: +57 stored in a byte in 1's complement form is Invert all bits to determine the 1's complement of 57 to be Problems Determine the 1's complement, in byte form, of the decimal integers a) 10 b) 45 c) 111
18 42 CHAPTER 3 2. Using a nibble, determine the 1's complement, of the decimal integers a) 6 b) 28 The 1's complement notation was popular in early digital systems. Integers in these early digital systems were stored in 1's complement form. There are still two representations of the integer 0 (can you give them?) and both addition and subtraction cannot be performed easily Converting from 1's Complement Notation to Decimal Notation We look only at integers stored in bytes in the following discussion. The same rules apply if an integer is stored in 4bits, 16bits, 32bits or other bit form. Case 1: The MSB of the Byte is 0 If a byte contains, for example, which represents an integer stored in 1's complement form, we know that since the MSB = 0, this is a positive integer. The decimal integer value of the byte then is : This 0 indicates the integer is positive Therefore which represent a binary number in 1's complement form is the decimal integer = +89 Case 2: The MSB of the Byte is 1 Method A  Reverse the Steps Carried out When Converting to 1's Complement Form Example In Example above we determined that 57 stored in a byte in 1's complement form is If you are told that a byte contains these same bits and that this information represents a decimal integer in 1's complement form, how would you determine that this represents the integer 57? Solution: If you know that the bits represent an integer in 1's complement form, first examine the MSB which is 1. This indicates the integer is negative. You inverted bits to find the 1's complement. Therefore, invert again and then take the magnitude of the resulting binary expression to find the decimal integer vale. When you invert all bits of you get The corresponding decimal integer is = +57. Therefore, the integer stored is 57. Method B  Add the Weight of all Bits Containing a 0
19 Number System and Codes 43 Time saving methods is always being sought in the computer industry. They can, indeed, be worth much money. In converting from 1's complement notation to decimal value notation in Method A above, we carried out three steps: Step 1: Examine the MSB. If it is 1, the integer is negative. Step 2: Invert each bit of the integer in 1's complement form. Step 3: Convert all bits (excluding the MSB) to corresponding decimal form. Steps 2 and 3 can be combined by adding the weight of all bits in the original representation containing a 0. In our example above, to convert to decimal, the MSB has value 1. Therefore, the integer is negative. Bits 5, 4, 3 and 0 have value 0. Therefore, the integer value is  ( ) = 57. These steps are summarized in the following table: Binary Number in 1's Complement Notation Weight of Bits Containing 0's This is the sign bit indicating the integer is negative Therefore which represents a binary number stored in 1's complement notation has decimal value ( ) = 57 Problems The following bytes represent integers in 1's complement form. Find their decimal values: a) b) c) d)
20 44 CHAPTER Problem Assignment Write all of the different representations of numbers in binary that can be stored in 1's complement form in a nibble and their corresponding decimal integer values. 1's Complement Representation Decimal Integer We now have three ways of representing integers in binary: true binary form, signmagnitude notation, and 1's complement notation. Complete the following table: A byte contains the following bits a) b) c) d) What integer does this byte represent if the bits represent an integer in pure binary form? What integer does this byte represent if the bits represent an integer using signmagnitude notation?. 3. Store +6 in 1's complement form using 4 bits. 4. Store 7 in 1's complement form using 4 bits. 5. Store +83 in 1's complement form in a byte. What integer does this byte represent if the bits represent an integer in 1's complement notation?
21 6. Store 107 in 1's complement form in a byte. Number System and Codes Convert the following numbers stored in 1's complement form in a byte to decimal: a) b) Express the decimal number 39 as an 8bit number in signmagnitude and 1's complement form. Answers Problems Problems a) 10 b) 45 c) a) 1001 b) +28 in binary is This number cannot be stored in a nibble. Problems a) b) c) d) Two's Complement Notation We saw in previous sections that there are different ways of storing binary numbers in computers. The number 50 can be stored in a byte in true binary form as When the sign of the number is relevant, as in a number such as +50, we can store it in a byte using signmagnitude notation as The MSB, which has value 0, indicates the number is positive. The number 50 is stored in a byte using signmagnitude notation as The MSB, which has value 1, indicates the number is negative. The number +50 can also be stored in a byte in 1's complement form as The number 50 is stored in a byte in 1's complement form as Problems Complete the following table: Integer to be Stored in a Byte n/a True Binary Representation Two's Complement Notation SignMagnitude Representation 1's Complement Representation The last notation that we look at is called the two s complement notation. The 2's complement notation is used almost exclusively in digital systems to store positive and negative integers. We look then at writing integers in binary in 2's complement form.
22 46 CHAPTER The 2's Complement in Binary of a Positive Integer As was the case with the 1's complement, the 2's complement of a positive number is no different from the representation of that number using signmagnitude notation. Example Store the integer +27 in a byte using signmagnitude form and using the two's complement form. +27 is stored exactly the same using either the signmagnitude notation or the 2's complement notation The number +27 is stored as: The MSB is 0 since the number is positive is 27 in binary. Example What is the decimal integer value of stored in a byte if the representation is: a) signmagnitude form b) 2's complement form? Solution: There is no difference between the forms. Since the MSB is 0, the number is positive. The other 7 bytes in decimal form is 89. The integer stored is +89. Problems Store these integers in bytes using the 2's complement notation: a) + 36 b) Storing Negative Integers in Bytes Using Two's Complement Notation We indicated in the last section that the formal way to determine the 1's complement of a negative integer to be stored in binary in n bits is to subtract the integer in binary from 2 n  1. It turned out that the short way to do this is to simply invert all the bits of the representation of the corresponding positive integer. Example To find the 1's complement of 77 we note that +77 in binary is Inverting bits, we determine that the representation of 77 in binary in 1's complement form is The formal way to determine the 2's complement of a negative integer to be stored in binary in n bits is to subtract the integer in binary from 2 n. To determine 1's complement of a negative integer to be stored in n bits you subtract from 2 n 1 and to find the 2 s complement of a negative integer to be stored in n bits you subtract from 2 n. It follows that the 2's complement is just 1 more than the 1's complement. This gives us a method to determine quickly the 2's complement of a negative integer. Rule: To determine the 2's complement of a negative integer, determine the 1's complement and add 1.
23 Example Store 27 in a byte using 2's complement notation. Steps 1 and 2 determine the 1's complement: Step 1: +27 in binary is Number System and Codes 47 Step 2: Invert bits to yield Then the complement of 27 is Step 3 is the additional step needed to find the 2's complement. Step 3: Add 1 to the 1's complement: The 2's complement of 27 is Example Store the integer 70 in a byte using the two's complement notation. The steps are carried out in the table that follows: Step Procedure Binary Answer in Byte Form 1 2 Write +70 in binary 70 = Take the one's complement (invert the contents of the byte) Add 1 to the LSB + 1 The answer is the two's complement of Therefore we store the integer 70 in a byte in 2's complement form as Problems Store 26 and 67 in bytes in 2's complement form Finding the Decimal Integer Values of Positive and Negative Numbers Stored in Bytes in 2's Complement Form Case 1: The MSB of the Byte is 0 If a byte contains the integer in 2's complement form, we know that since the MSB = 0, this is a positive integer. The integer value of the byte then is = +89 in decimal. Case 2: The MSB of the Byte is 1 If a byte contains the integer in 2'complement form, we know that since the MSB = 1, the integer is negative. The quickest way to find the decimal value for the integer is to add the weight of all columns containing a 0 and then add 1 to the result.
24 48 CHAPTER 3 The decimal integer value of is Sign represents the integer 39 (Remember to add +1) Check: Write 39 in 2's complement byte form: Step Procedure Binary Answer in Byte Form 1 2 Write +39 in binary 39 = Take the one's complement (invert the contents of the byte) Add 1 to the LSB + 1 The answer is the two's complement of Therefore we store the integer 39 in a byte in 2's complement form as This is the binary representation in 2's complement form that we were asked to convert to a decimal integer Problem Assignment Determine the integer decimal equivalent of the following bytesized 2's complement numbers: a) b) c) d) Write the 16 different 2's complement representations of decimal integers that can be stored in a nybble and their corresponding decimal integer values. 2's Complement Representation Decimal Integer
25 Number System and Codes We now have four ways of representing integers in binary: true binary form, signmagnitude notation, 1's complement notation, and 2's complement notation. Complete the following table: A byte contains the following bits a) b) c) d) What decimal integer is stored in the byte for each of the following representations: True binary Signmagnitude 1's Complement. 4. a) Store +6 in 2's complement form using 4 bits. b) Store 7 in 1's complement form using 4 bits. 2's Complement 5. Convert the following numbers stored in 2's complement form in a byte to decimal: a) b) Express the decimal number 39 as an 8bit number in signmagnitude, 1's complement, and 2's complement form. 7. How many representations of the integer zero are there in the 2's complement notation using bytes? 8. We have learned to store integers in true binary form, signmagnitude form, 1's complement form, and 2's complement form. There are additional ways. One other way is called BCD form. Answers Problems Integer to be Stored in a Byte True Binary Representation SignMagnitude Representation 1's Complement Representation n/a Problems Store these integers in bytes using the 2's complement notation: a) b) in binary is This integer is too large to be stored in 2's complement form in a byte. Problems Problem Assignment a) b) c) d)
26 50 CHAPTER 3 2's Complement Representation Decimal Integer A byte contains the following bits What decimal integer is stored in the byte for each of the following representations: True binary Signmagnitude 1's Complement 2's Complement a) b) c) d) = a) 0110 b) a) b) signmagnitude 's complement 's complement Just Two's Complement Arithmetic We have been discussing storing information, particularly integers, in computers mostly in byte form. In this section we look at how addition and subtraction are performed in modern computers. To perform mathematical functions, a computer's central processing unit, or CPU, contains several circuits, and one of these circuits is called the arithmeticlogic unit or ALU.
27 Number System and Codes 51 This unit is the number crunching circuit of every digital system, and, as its name implies, it can be controlled to perform arithmetic operations such as addition and subtraction or logic operations such as AND and OR (which we shall deal with in the next unit). A schematic of a simplified ALU is drawn below. You can see that the arithmeticlogic unit has two parallel inputs, one parallel output, and a set of function select control lines. If we wanted to add two integers, for example, the two integers would be retrieved, probably from memory, and would become inputs to the ALU. The function select part of the ALU would allow the decision to be made to add the numbers. The integers would be added [we shall describe how that addition occurs electronically in the next unit] most likely using 2's complement arithmetic. The sum of the integers would be the output from the ALU. The schematic and the explanation of addition are highly simplified. For example, the Intel Pentium 4 microprocessor has 6 integer execution units, and each of them has a 32bit ALU. The ALU has to be able to perform the four basic operations, namely addition, subtraction, multiplication and division. One might think that there would be four separate circuits in the ALU, one for each of these operations. That is not the case since all four operations can be performed using a binaryadder circuit. [We shall look at a binaryadder circuit in the next unit when we discuss logic gates.] The fact that all numbers are stored in 2's complement form allows the ALU to use just one circuit for all four basic mathematical operations of addition, subtraction, multiplication and division. In this section we shall show that subtractions can be written as additions. Although we do not discuss multiplication and division in this course, multiplications can be thought of as repeated additions and divisions as repeated subtractions. Having one circuit able to perform all four mathematical operations in the ALU means that the circuit is small and fast to operate. In addition, it consumes very little power and is cheap to manufacture.
28 52 CHAPTER 3 We are now going to look at adding and subtracting in 2's complement notation. Although we shall not look at circuit design until the next unit, we are going to start at this point to look at what would have to be incorporated into a circuit design to deal with the various situations which occur when you add or subtract integers Adding Positive Integers in 2's Complement Form In the examples that follow, variables will be used to represent integers. This is consistent with what actually happens when you process numbers in a computer. When you write a computer program, you may include statements such as cost = 100 sales tax = 7 total cost = cost + sales tax When the program is run, the variable names cost and sales tax and their values would be stored in the computer's memory. The value of the variable total cost would be determined by retrieving the values of cost and sales tax and inputting them to the ALU. After the values of the variables are added in the ALU, the output would be the value of the variable total cost. And, of course, every letter of every variable would be stored in a byte [likely in ASCII form] as a true binary number. The values of the variables would be stored as signed number in 2's complement form. We want to look now at how signed integers such as +100 and +7, stored using 2's complement notation, are added and subtracted. Example If R = +9 and S = +5, find R + S in byteform using 2's complement. Solution: Each of the integers is written in 2's complement notation [remember that these representations are the same as signmagnitude notation.] The two integers are then added using regular binary addition. Decimal Addition 2's Complement Addition Overflow in Binary Addition The largest positive integer that can be stored in a byte in 2's complement form is +127, that is Therefore, any time two positive 2's complement integers are added and the sum of the integers is greater than +127 an overflow will occur. This situation is illustrated in Example when +100 and +30 are added.
29 Example If R = +100 and S = +30, find R + S Solution: Decimal Addition Number System and Codes 53 2's Complement Addition The sum of the two integers here is indicated to be Clearly, this sum cannot be a correct representation of the actual sum of +130 because the MSB is 1 which indicates that this binary expression represents a negative number in 2's complement notation. [What negative integer is represented by ? How is this related to the actual sum of +100 and +30?] If we designed a circuit to add two positive numbers, some part of the circuit would have to determine when an overflow occurs. The rule is: 2's complement overflow occurs when the carry into the MSB is not equal to the carry out from the MSB. An overflow detector circuit makes this determination. The schematic below illustrates this concept. The concept of overflow is examined by looking again at Example and Example Example Add +9 and +5 using 2's complement notation. Decimal Addition 2's Complement Addition
30 54 CHAPTER 3 The following graphic illustrates what happens in bits 5, 6 and 7 as they are added. In particular, we are interested in the values of the carry in to byte 7 and the carry out from byte 7. If they are equal, no overflow occurs. Both the carry in and carry out values for bit 7, the MSB, have value 0. No overflow occurs. Example Add +100 and +30. Show that an overflow occurs by checking the carry in to and the carry out from the MSB of the sum. Decimal Addition 2's Complement Addition The carry in to the MSB of 1 is not equal to the carry out of 0 from the MSB. An overflow occurs.
Base Conversion written by Cathy Saxton
Base Conversion written by Cathy Saxton 1. Base 10 In base 10, the digits, from right to left, specify the 1 s, 10 s, 100 s, 1000 s, etc. These are powers of 10 (10 x ): 10 0 = 1, 10 1 = 10, 10 2 = 100,
More informationOct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8
ECE Department Summer LECTURE #5: Number Systems EEL : Digital Logic and Computer Systems Based on lecture notes by Dr. Eric M. Schwartz Decimal Number System: Our standard number system is base, also
More informationBinary Numbers. Bob Brown Information Technology Department Southern Polytechnic State University
Binary Numbers Bob Brown Information Technology Department Southern Polytechnic State University Positional Number Systems The idea of number is a mathematical abstraction. To use numbers, we must represent
More informationNumber Systems, Base Conversions, and Computer Data Representation
, Base Conversions, and Computer Data Representation Decimal and Binary Numbers When we write decimal (base 10) numbers, we use a positional notation system. Each digit is multiplied by an appropriate
More informationLSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology
LSN 2 Number Systems Department of Engineering Technology LSN 2 Decimal Number System Decimal number system has 10 digits (09) Base 10 weighting system... 10 5 10 4 10 3 10 2 10 1 10 0. 101 102 103
More informationSigned Binary Arithmetic
Signed Binary Arithmetic In the real world of mathematics, computers must represent both positive and negative binary numbers. For example, even when dealing with positive arguments, mathematical operations
More informationEE 261 Introduction to Logic Circuits. Module #2 Number Systems
EE 261 Introduction to Logic Circuits Module #2 Number Systems Topics A. Number System Formation B. Base Conversions C. Binary Arithmetic D. Signed Numbers E. Signed Arithmetic F. Binary Codes Textbook
More informationLecture 11: Number Systems
Lecture 11: Number Systems Numeric Data Fixed point Integers (12, 345, 20567 etc) Real fractions (23.45, 23., 0.145 etc.) Floating point such as 23. 45 e 12 Basically an exponent representation Any number
More information2011, The McGrawHill Companies, Inc. Chapter 3
Chapter 3 3.1 Decimal System The radix or base of a number system determines the total number of different symbols or digits used by that system. The decimal system has a base of 10 with the digits 0 through
More informationSection 1.4 Place Value Systems of Numeration in Other Bases
Section.4 Place Value Systems of Numeration in Other Bases Other Bases The HinduArabic system that is used in most of the world today is a positional value system with a base of ten. The simplest reason
More informationTo convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:
Binary Numbers In computer science we deal almost exclusively with binary numbers. it will be very helpful to memorize some binary constants and their decimal and English equivalents. By English equivalents
More informationBinary Numbers. Binary Octal Hexadecimal
Binary Numbers Binary Octal Hexadecimal Binary Numbers COUNTING SYSTEMS UNLIMITED... Since you have been using the 10 different digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 all your life, you may wonder how
More informationBinary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.
Binary Representation The basis of all digital data is binary representation. Binary  means two 1, 0 True, False Hot, Cold On, Off We must be able to handle more than just values for real world problems
More informationNUMBER SYSTEMS. 1.1 Introduction
NUMBER SYSTEMS 1.1 Introduction There are several number systems which we normally use, such as decimal, binary, octal, hexadecimal, etc. Amongst them we are most familiar with the decimal number system.
More informationNumber and codes in digital systems
Number and codes in digital systems Decimal Numbers You are familiar with the decimal number system because you use them everyday. But their weighted structure is not understood. In the decimal number
More informationComputer Science 281 Binary and Hexadecimal Review
Computer Science 281 Binary and Hexadecimal Review 1 The Binary Number System Computers store everything, both instructions and data, by using many, many transistors, each of which can be in one of two
More information= Chapter 1. The Binary Number System. 1.1 Why Binary?
Chapter The Binary Number System. Why Binary? The number system that you are familiar with, that you use every day, is the decimal number system, also commonly referred to as the base0 system. When you
More information6 3 4 9 = 6 10 + 3 10 + 4 10 + 9 10
Lesson The Binary Number System. Why Binary? The number system that you are familiar with, that you use every day, is the decimal number system, also commonly referred to as the base system. When you
More informationActivity 1: Bits and Bytes
ICS3U (Java): Introduction to Computer Science, Grade 11, University Preparation Activity 1: Bits and Bytes The Binary Number System Computers use electrical circuits that include many transistors and
More informationCSI 333 Lecture 1 Number Systems
CSI 333 Lecture 1 Number Systems 1 1 / 23 Basics of Number Systems Ref: Appendix C of Deitel & Deitel. Weighted Positional Notation: 192 = 2 10 0 + 9 10 1 + 1 10 2 General: Digit sequence : d n 1 d n 2...
More informationNumbering Systems. InThisAppendix...
G InThisAppendix... Introduction Binary Numbering System Hexadecimal Numbering System Octal Numbering System Binary Coded Decimal (BCD) Numbering System Real (Floating Point) Numbering System BCD/Binary/Decimal/Hex/Octal
More informationCDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012
CDA 3200 Digital Systems Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012 Outline Data Representation Binary Codes Why 6311 and Excess3? Data Representation (1/2) Each numbering
More informationELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE470/570: MicroprocessorBased System Design Fall 2014.
REVIEW OF NUMBER SYSTEMS Notes Unit 2 BINARY NUMBER SYSTEM In the decimal system, a decimal digit can take values from to 9. For the binary system, the counterpart of the decimal digit is the binary digit,
More informationThe string of digits 101101 in the binary number system represents the quantity
Data Representation Section 3.1 Data Types Registers contain either data or control information Control information is a bit or group of bits used to specify the sequence of command signals needed for
More informationCHAPTER 3 Numbers and Numeral Systems
CHAPTER 3 Numbers and Numeral Systems Numbers play an important role in almost all areas of mathematics, not least in calculus. Virtually all calculus books contain a thorough description of the natural,
More informationNumber Representation
Number Representation CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Topics to be Discussed How are numeric data
More informationChapter 2. Binary Values and Number Systems
Chapter 2 Binary Values and Number Systems Numbers Natural numbers, a.k.a. positive integers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645, 32 Negative numbers A
More informationUseful Number Systems
Useful Number Systems Decimal Base = 10 Digit Set = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} Binary Base = 2 Digit Set = {0, 1} Octal Base = 8 = 2 3 Digit Set = {0, 1, 2, 3, 4, 5, 6, 7} Hexadecimal Base = 16 = 2
More informationCS 16: Assembly Language Programming for the IBM PC and Compatibles
CS 16: Assembly Language Programming for the IBM PC and Compatibles First, a little about you Your name Have you ever worked with/used/played with assembly language? If so, talk about it Why are you taking
More informationBinary, Hexadecimal, Octal, and BCD Numbers
23CH_PHCalter_TMSETE_949118 23/2/2007 1:37 PM Page 1 Binary, Hexadecimal, Octal, and BCD Numbers OBJECTIVES When you have completed this chapter, you should be able to: Convert between binary and decimal
More informationCPEN 214  Digital Logic Design Binary Systems
CPEN 4  Digital Logic Design Binary Systems C. Gerousis Digital Design 3 rd Ed., Mano Prentice Hall Digital vs. Analog An analog system has continuous range of values A mercury thermometer Vinyl records
More informationBinary Representation
Binary Representation The basis of all digital data is binary representation. Binary  means two 1, 0 True, False Hot, Cold On, Off We must tbe able to handle more than just values for real world problems
More informationBinary math. Resources and methods for learning about these subjects (list a few here, in preparation for your research):
Binary math This worksheet and all related files are licensed under the Creative Commons Attribution License, version 1.0. To view a copy of this license, visit http://creativecommons.org/licenses/by/1.0/,
More information3. Convert a number from one number system to another
3. Convert a number from one number system to another Conversion between number bases: Hexa (16) Decimal (10) Binary (2) Octal (8) More Interest Way we need conversion? We need decimal system for real
More informationLecture 2. Binary and Hexadecimal Numbers
Lecture 2 Binary and Hexadecimal Numbers Purpose: Review binary and hexadecimal number representations Convert directly from one base to another base Review addition and subtraction in binary representations
More informationNumber Systems. Introduction / Number Systems
Number Systems Introduction / Number Systems Data Representation Data representation can be Digital or Analog In Analog representation values are represented over a continuous range In Digital representation
More informationData Representation. Data Representation, Storage, and Retrieval. Data Representation. Data Representation. Data Representation. Data Representation
, Storage, and Retrieval ULM/HHIM Summer Program Project 3, Day 3, Part 3 Digital computers convert the data they process into a digital value. Text Audio Images/Graphics Video Digitizing 00000000... 6/8/20
More informationNumber Conversions Dr. Sarita Agarwal (Acharya Narendra Dev College,University of Delhi)
Conversions Dr. Sarita Agarwal (Acharya Narendra Dev College,University of Delhi) INTRODUCTION System A number system defines a set of values to represent quantity. We talk about the number of people
More informationChapter 6 Digital Arithmetic: Operations & Circuits
Chapter 6 Digital Arithmetic: Operations & Circuits Chapter 6 Objectives Selected areas covered in this chapter: Binary addition, subtraction, multiplication, division. Differences between binary addition
More informationBinary Numbers The Computer Number System
Binary Numbers The Computer Number System Number systems are simply ways to count things. Ours is the base0 or radix0 system. Note that there is no symbol for 0 or for the base of any system. We count,2,3,4,5,6,7,8,9,
More informationplc numbers  13.1 Encoded values; BCD and ASCII Error detection; parity, gray code and checksums
plc numbers  3. Topics: Number bases; binary, octal, decimal, hexadecimal Binary calculations; s compliments, addition, subtraction and Boolean operations Encoded values; BCD and ASCII Error detection;
More informationDigital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture  04 Digital Logic II May, I before starting the today s lecture
More information198:211 Computer Architecture
198:211 Computer Architecture Topics: Lecture 8 (W5) Fall 2012 Data representation 2.1 and 2.2 of the book Floating point 2.4 of the book 1 Computer Architecture What do computers do? Manipulate stored
More informationEverything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6
Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6 Number Systems No course on programming would be complete without a discussion of the Hexadecimal (Hex) number
More informationNUMBER SYSTEMS. William Stallings
NUMBER SYSTEMS William Stallings The Decimal System... The Binary System...3 Converting between Binary and Decimal...3 Integers...4 Fractions...5 Hexadecimal Notation...6 This document available at WilliamStallings.com/StudentSupport.html
More informationChapter 4: Computer Codes
Slide 1/30 Learning Objectives In this chapter you will learn about: Computer data Computer codes: representation of data in binary Most commonly used computer codes Collating sequence 36 Slide 2/30 Data
More informationDecimal Numbers: Base 10 Integer Numbers & Arithmetic
Decimal Numbers: Base 10 Integer Numbers & Arithmetic Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 3271 = (3x10 3 ) + (2x10 2 ) + (7x10 1 )+(1x10 0 ) Ward 1 Ward 2 Numbers: positional notation Number
More informationBinary Adders: Half Adders and Full Adders
Binary Adders: Half Adders and Full Adders In this set of slides, we present the two basic types of adders: 1. Half adders, and 2. Full adders. Each type of adder functions to add two binary bits. In order
More informationLevent EREN levent.eren@ieu.edu.tr A306 Office Phone:4889882 INTRODUCTION TO DIGITAL LOGIC
Levent EREN levent.eren@ieu.edu.tr A306 Office Phone:4889882 1 Number Systems Representation Positive radix, positional number systems A number with radix r is represented by a string of digits: A n
More informationToday. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real Time Systems: Binary Arithmetic
Today Binary addition Representing negative numbers 2 Binary Addition Consider the following binary numbers: 0 0 1 0 0 1 1 0 0 0 1 0 1 0 1 1 How do we add these numbers? 3 Binary Addition 0 0 1 0 0 1 1
More informationUnsigned Conversions from Decimal or to Decimal and other Number Systems
Page 1 of 5 Unsigned Conversions from Decimal or to Decimal and other Number Systems In all digital design, analysis, troubleshooting, and repair you will be working with binary numbers (or base 2). It
More informationCOMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012
Binary numbers The reason humans represent numbers using decimal (the ten digits from 0,1,... 9) is that we have ten fingers. There is no other reason than that. There is nothing special otherwise about
More information4 BOOLEAN ALGEBRA AND LOGIC SIMPLIFICATION
4 BOOLEAN ALGEBRA AND LOGIC SIMPLIFICATION BOOLEAN OPERATIONS AND EXPRESSIONS Variable, complement, and literal are terms used in Boolean algebra. A variable is a symbol used to represent a logical quantity.
More informationCHAPTER TWO. 2.1 Unsigned Binary Counting. Numbering Systems
CHAPTER TWO Numbering Systems Chapter one discussed how computers remember numbers using transistors, tiny devices that act like switches with only two positions, on or off. A single transistor, therefore,
More informationDecimal to Binary Conversion
Decimal to Binary Conversion A tool that makes the conversion of decimal values to binary values simple is the following table. The first row is created by counting right to left from one to eight, for
More informationCounting in base 10, 2 and 16
Counting in base 10, 2 and 16 1. Binary Numbers A superimportant fact: (Nearly all) Computers store all information in the form of binary numbers. Numbers, characters, images, music files  all of these
More informationMemory Systems. Static Random Access Memory (SRAM) Cell
Memory Systems This chapter begins the discussion of memory systems from the implementation of a single bit. The architecture of memory chips is then constructed using arrays of bit implementations coupled
More information2 Number Systems. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:
2 Number Systems 2.1 Source: Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Understand the concept of number systems. Distinguish
More informationSystems I: Computer Organization and Architecture
Systems I: Computer Organization and Architecture Lecture 2: Number Systems and Arithmetic Number Systems  Base The number system that we use is base : 734 = + 7 + 3 + 4 = x + 7x + 3x + 4x = x 3 + 7x
More informationChapter 1: Digital Systems and Binary Numbers
Chapter 1: Digital Systems and Binary Numbers Digital age and information age Digital computers general purposes many scientific, industrial and commercial applications Digital systems telephone switching
More informationDigital codes. Resources and methods for learning about these subjects (list a few here, in preparation for your research):
Digital codes This worksheet and all related files are licensed under the Creative Commons Attribution License, version 1.0. To view a copy of this license, visit http://creativecommons.org/licenses/by/1.0/,
More informationBits, Bytes, and Codes
Bits, Bytes, and Codes Telecommunications 1 Peter Mathys Black and White Image Suppose we want to draw a B&W image on a computer screen. We first subdivide the screen into small rectangles or squares called
More informationComputer Systems. Computer Systems COMP1208. Objectives of the Module. Course Assessment. Reading List. What will you need
Computer Systems Computer Systems Lecturer: Ruth Coffey Room KE4027, email: ruth.coffey@dit.ie Today s Lecture >> Module Overview Objectives of Module Course Assessment Reading List Introduction to Computer
More informationGoals. Unary Numbers. Decimal Numbers. 3,148 is. 1000 s 100 s 10 s 1 s. Number Bases 1/12/2009. COMP370 Intro to Computer Architecture 1
Number Bases //9 Goals Numbers Understand binary and hexadecimal numbers Be able to convert between number bases Understand binary fractions COMP37 Introduction to Computer Architecture Unary Numbers Decimal
More informationDigital Design. Assoc. Prof. Dr. Berna Örs Yalçın
Digital Design Assoc. Prof. Dr. Berna Örs Yalçın Istanbul Technical University Faculty of Electrical and Electronics Engineering Office Number: 2318 Email: siddika.ors@itu.edu.tr Grading 1st Midterm 
More informationNumber Systems I. CIS0082 Logic and Foundations of Mathematics. David Goodwin. 11:00, Tuesday 18 th October
Number Systems I CIS0082 Logic and Foundations of Mathematics David Goodwin david.goodwin@perisic.com 11:00, Tuesday 18 th October 2011 Outline 1 Number systems Numbers Natural numbers Integers Rational
More informationBinary. ! You are probably familiar with decimal
Arithmetic operations in assembly language Prof. Gustavo Alonso Computer Science Department ETH Zürich alonso@inf.ethz.ch http://www.inf.ethz.ch/department/is/iks/ Binary! You are probably familiar with
More informationA Step towards an Easy Interconversion of Various Number Systems
A towards an Easy Interconversion of Various Number Systems Shahid Latif, Rahat Ullah, Hamid Jan Department of Computer Science and Information Technology Sarhad University of Science and Information Technology
More informationNumber Systems and Radix Conversion
Number Systems and Radix Conversion Sanjay Rajopadhye, Colorado State University 1 Introduction These notes for CS 270 describe polynomial number systems. The material is not in the textbook, but will
More information2 Number Systems 2.1. Foundations of Computer Science Cengage Learning
2 Number Systems 2.1 Foundations of Computer Science Cengage Learning 2.2 Objectives After studying this chapter, the student should be able to: Understand the concept of number systems. Distinguish between
More informationCS101 Lecture 11: Number Systems and Binary Numbers. Aaron Stevens 14 February 2011
CS101 Lecture 11: Number Systems and Binary Numbers Aaron Stevens 14 February 2011 1 2 1 3!!! MATH WARNING!!! TODAY S LECTURE CONTAINS TRACE AMOUNTS OF ARITHMETIC AND ALGEBRA PLEASE BE ADVISED THAT CALCULTORS
More informationNumeral Systems. The number twentyfive can be represented in many ways: Decimal system (base 10): 25 Roman numerals:
Numeral Systems Which number is larger? 25 8 We need to distinguish between numbers and the symbols that represent them, called numerals. The number 25 is larger than 8, but the numeral 8 above is larger
More informationMODULAR ARITHMETIC. a smallest member. It is equivalent to the Principle of Mathematical Induction.
MODULAR ARITHMETIC 1 Working With Integers The usual arithmetic operations of addition, subtraction and multiplication can be performed on integers, and the result is always another integer Division, on
More informationSolution for Homework 2
Solution for Homework 2 Problem 1 a. What is the minimum number of bits that are required to uniquely represent the characters of English alphabet? (Consider upper case characters alone) The number of
More information4.3 TABLE 3 TABLE 4. 1342 five 1 125 3 25 4 5 2 1 125 75 20 2 222.
.3 Conversion Between Number Bases 169.3 Conversion Between Number Bases Although the numeration systems discussed in the opening section were all base ten, other bases have occurred historically. For
More informationBINARY CODED DECIMAL: B.C.D.
BINARY CODED DECIMAL: B.C.D. ANOTHER METHOD TO REPRESENT DECIMAL NUMBERS USEFUL BECAUSE MANY DIGITAL DEVICES PROCESS + DISPLAY NUMBERS IN TENS IN BCD EACH NUMBER IS DEFINED BY A BINARY CODE OF 4 BITS.
More informationMachine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.
1 Topics Machine Architecture and Number Systems Major Computer Components Bits, Bytes, and Words The Decimal Number System The Binary Number System Converting from Decimal to Binary Major Computer Components
More informationBinary Division. Decimal Division. Hardware for Binary Division. Simple 16bit Divider Circuit
Decimal Division Remember 4th grade long division? 43 // quotient 12 521 // divisor dividend 480 4136 5 // remainder Shift divisor left (multiply by 10) until MSB lines up with dividend s Repeat until
More informationGrade 6 Math Circles. Binary and Beyond
Faculty of Mathematics Waterloo, Ontario N2L 3G1 The Decimal System Grade 6 Math Circles October 15/16, 2013 Binary and Beyond The cool reality is that we learn to count in only one of many possible number
More informationNumeration systems. Resources and methods for learning about these subjects (list a few here, in preparation for your research):
Numeration systems This worksheet and all related files are licensed under the Creative Commons Attribution License, version 1.0. To view a copy of this license, visit http://creativecommons.org/licenses/by/1.0/,
More informationUnit 1 Number Sense. In this unit, students will study repeating decimals, percents, fractions, decimals, and proportions.
Unit 1 Number Sense In this unit, students will study repeating decimals, percents, fractions, decimals, and proportions. BLM Three Types of Percent Problems (p L34) is a summary BLM for the material
More informationThe Hexadecimal Number System and Memory Addressing
APPENDIX C The Hexadecimal Number System and Memory Addressing U nderstanding the number system and the coding system that computers use to store data and communicate with each other is fundamental to
More informationAddition Methods. Methods Jottings Expanded Compact Examples 8 + 7 = 15
Addition Methods Methods Jottings Expanded Compact Examples 8 + 7 = 15 48 + 36 = 84 or: Write the numbers in columns. Adding the tens first: 47 + 76 110 13 123 Adding the units first: 47 + 76 13 110 123
More informationThe Essentials of Computer Organization and Architecture. Linda Null and Julia Lobur Jones and Bartlett Publishers, 2003
The Essentials of Computer Organization and Architecture Linda Null and Julia Lobur Jones and Bartlett Publishers, 2003 Chapter 2 Instructor's Manual Chapter Objectives Chapter 2, Data Representation,
More informationChapter 7 Lab  Decimal, Binary, Octal, Hexadecimal Numbering Systems
Chapter 7 Lab  Decimal, Binary, Octal, Hexadecimal Numbering Systems This assignment is designed to familiarize you with different numbering systems, specifically: binary, octal, hexadecimal (and decimal)
More informationDecimal Number (base 10) Binary Number (base 2)
LECTURE 5. BINARY COUNTER Before starting with counters there is some vital information that needs to be understood. The most important is the fact that since the outputs of a digital chip can only be
More informationInteger multiplication
Integer multiplication Suppose we have two unsigned integers, A and B, and we wish to compute their product. Let A be the multiplicand and B the multiplier: A n 1... A 1 A 0 multiplicand B n 1... B 1 B
More informationA single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc
Other architectures Example. Accumulatorbased machines A single register, called the accumulator, stores the operand before the operation, and stores the result after the operation. Load x # into acc
More informationCS201: Architecture and Assembly Language
CS201: Architecture and Assembly Language Lecture Three Brendan Burns CS201: Lecture Three p.1/27 Arithmetic for computers Previously we saw how we could represent unsigned numbers in binary and how binary
More information1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:
Exercises 1  number representations Questions 1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal: (a) 3012 (b)  435 2. For each of
More informationTYPES OF NUMBERS. Example 2. Example 1. Problems. Answers
TYPES OF NUMBERS When two or more integers are multiplied together, each number is a factor of the product. Nonnegative integers that have exactly two factors, namely, one and itself, are called prime
More informationManagement Challenge. Managing Hardware Assets. Central Processing Unit. What is a Computer System?
Management Challenge Managing Hardware Assets What computer processing and storage capability does our organization need to handle its information and business transactions? What arrangement of computers
More informationPositional Numbering System
APPENDIX B Positional Numbering System A positional numbering system uses a set of symbols. The value that each symbol represents, however, depends on its face value and its place value, the value associated
More informationLecture 8: Binary Multiplication & Division
Lecture 8: Binary Multiplication & Division Today s topics: Addition/Subtraction Multiplication Division Reminder: get started early on assignment 3 1 2 s Complement Signed Numbers two = 0 ten 0001 two
More informationCOMBINATIONAL CIRCUITS
COMBINATIONAL CIRCUITS http://www.tutorialspoint.com/computer_logical_organization/combinational_circuits.htm Copyright tutorialspoint.com Combinational circuit is a circuit in which we combine the different
More informationMULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
CHAPTER01 QUESTIONS MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) Convert binary 010101 to octal. 1) A) 258 B) 58 C) 218 D) 158 2) Any number
More informationSection 1.5 Arithmetic in Other Bases
Section Arithmetic in Other Bases Arithmetic in Other Bases The operations of addition, subtraction, multiplication and division are defined for counting numbers independent of the system of numeration
More information#5. Show and the AND function can be constructed from two NAND gates.
Study Questions for Digital Logic, Processors and Caches G22.0201 Fall 2009 ANSWERS Digital Logic Read: Sections 3.1 3.3 in the textbook. Handwritten digital lecture notes on the course web page. Study
More informationDecimals and other fractions
Chapter 2 Decimals and other fractions How to deal with the bits and pieces When drugs come from the manufacturer they are in doses to suit most adult patients. However, many of your patients will be very
More information4 Operations On Data
4 Operations On Data 4.1 Source: Foundations of Computer Science Cengage Learning Objectives After studying this chapter, students should be able to: List the three categories of operations performed on
More information