CHAPTER 3 Number System and Codes

Size: px
Start display at page:

Download "CHAPTER 3 Number System and Codes"

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 8-bit register is one which can hold up to 8 digits. Many computers work with 8-bit registers or multiples of 8-bit registers (that is 16, 24, 32, etc). a) How many different binary representations can be stored in an 8-bit register? b) Repeat a) for a 16 bit register c) Generalize to come up with a rule: If you have an x-bit 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 8-bit register? in a 16-bit 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 - Sign-Magnitude 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 xy-plane. 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 Sign-Magnitude 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 sign-magnitude 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 Sign-Magnitude Notation Example When a 4-bit sign-magnitude 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 4-bit sign-magnitude 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 sign-magnitude notation Problem How many positive binary numbers can be represented in a byte using the signmagnitude notation? Representation of Negative Integers using Sign-Magnitude Notation Example When an 8-bit sign-magnitude 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 4-bit sign-magnitude 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 (4-bits) in binary using the sign-magnitude 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 sign-magnitude integers? Write '-93' in sign-magnitude representation, using an 8-bit register. 5. What is the largest positive number which can be represented in an 8-bit register, using the sign-magnitude method of representation? 6. What is the largest negative number which can be represented in an 8-bit register, using the sign-magnitude method of representation? 7. Give the range of possible numbers which can be represented in a 16-bit register, using the sign-magnitude method. 8. A drawback to the sign-magnitude 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 sign-magnitude 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 sign-magnitude 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 sign-magnitude form is used? b) +147 c) -17 d) -57 As indicated in the above problems, a drawback to using the sign-magnitude 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 sign-magnitude 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 sign-magnitude 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 sign-magnitude notation. The sign-magnitude 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 sign-magnitude 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 sign-magnitude notation. Can you explain why the sign-magnitude representation of -47 stored in a byte using signmagnitude notation is ? We also saw that there are two representations of the integer 0 using sign-magnitude 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 sign-magnitude 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 sign-magnitude 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 4-bits, 16-bits, 32-bits 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 sign-magnitude 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 8-bit number in sign-magnitude 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 sign-magnitude notation as The MSB, which has value 0, indicates the number is positive. The number -50 is stored in a byte using sign-magnitude 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 Sign-Magnitude 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 sign-magnitude notation. Example Store the integer +27 in a byte using sign-magnitude form and using the two's complement form. +27 is stored exactly the same using either the sign-magnitude 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) sign-magnitude 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 byte-sized 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 8-bit number in sign-magnitude, 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, sign-magnitude 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 Sign-Magnitude 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) sign-magnitude '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 arithmetic-logic 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 arithmetic-logic 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 32-bit 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 binary-adder circuit. [We shall look at a binary-adder 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 byte-form using 2's complement. Solution: Each of the integers is written in 2's complement notation [remember that these representations are the same as sign-magnitude 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 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 information

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

Oct: 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 information

LSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology

LSN 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 (0-9) Base 10 weighting system... 10 5 10 4 10 3 10 2 10 1 10 0. 10-1 10-2 10-3

More information

Lecture 11: Number Systems

Lecture 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 information

EE 261 Introduction to Logic Circuits. Module #2 Number Systems

EE 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 information

2011, The McGraw-Hill Companies, Inc. Chapter 3

2011, The McGraw-Hill 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 information

NUMBER SYSTEMS. 1.1 Introduction

NUMBER 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 information

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

To 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 information

Computer Science 281 Binary and Hexadecimal Review

Computer 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

Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

Binary 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 information

Number and codes in digital systems

Number 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 information

Section 1.4 Place Value Systems of Numeration in Other Bases

Section 1.4 Place Value Systems of Numeration in Other Bases Section.4 Place Value Systems of Numeration in Other Bases Other Bases The Hindu-Arabic system that is used in most of the world today is a positional value system with a base of ten. The simplest reason

More information

Binary Numbers. Binary Octal Hexadecimal

Binary 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 information

6 3 4 9 = 6 10 + 3 10 + 4 10 + 9 10

6 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 information

CSI 333 Lecture 1 Number Systems

CSI 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 information

The string of digits 101101 in the binary number system represents the quantity

The 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 information

CDA 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 CDA 3200 Digital Systems Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012 Outline Data Representation Binary Codes Why 6-3-1-1 and Excess-3? Data Representation (1/2) Each numbering

More information

Numbering Systems. InThisAppendix...

Numbering 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 information

Number Representation

Number 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 information

Binary, Hexadecimal, Octal, and BCD Numbers

Binary, 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 information

3. Convert a number from one number system to another

3. 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 information

Lecture 2. Binary and Hexadecimal Numbers

Lecture 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 information

Useful Number Systems

Useful 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 information

CPEN 214 - Digital Logic Design Binary Systems

CPEN 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 information

Binary Representation

Binary 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 information

Digital 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 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 information

Chapter 2. Binary Values and Number Systems

Chapter 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 information

plc numbers - 13.1 Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

plc 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 information

Chapter 4: Computer Codes

Chapter 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 information

Everything 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 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 information

Number Conversions Dr. Sarita Agarwal (Acharya Narendra Dev College,University of Delhi)

Number 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 information

Binary Adders: Half Adders and Full Adders

Binary 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 information

Number Systems. Introduction / Number Systems

Number 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 information

NUMBER SYSTEMS. William Stallings

NUMBER 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 information

Levent EREN levent.eren@ieu.edu.tr A-306 Office Phone:488-9882 INTRODUCTION TO DIGITAL LOGIC

Levent EREN levent.eren@ieu.edu.tr A-306 Office Phone:488-9882 INTRODUCTION TO DIGITAL LOGIC Levent EREN levent.eren@ieu.edu.tr A-306 Office Phone:488-9882 1 Number Systems Representation Positive radix, positional number systems A number with radix r is represented by a string of digits: A n

More information

Systems I: Computer Organization and Architecture

Systems 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 information

Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

Today. 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 information

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

COMP 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 information

Unsigned Conversions from Decimal or to Decimal and other Number Systems

Unsigned 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 information

A Step towards an Easy Interconversion of Various Number Systems

A 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 information

Memory Systems. Static Random Access Memory (SRAM) Cell

Memory 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 information

Digital codes. Resources and methods for learning about these subjects (list a few here, in preparation for your research):

Digital 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 information

Counting in base 10, 2 and 16

Counting in base 10, 2 and 16 Counting in base 10, 2 and 16 1. Binary Numbers A super-important fact: (Nearly all) Computers store all information in the form of binary numbers. Numbers, characters, images, music files --- all of these

More information

Number Systems and Radix Conversion

Number 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 information

2 Number Systems. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

2 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 information

Chapter 1: Digital Systems and Binary Numbers

Chapter 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 information

Goals. 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

Goals. 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 information

4.3 TABLE 3 TABLE 4. 1342 five 1 125 3 25 4 5 2 1 125 75 20 2 222.

4.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 information

Numeral Systems. The number twenty-five can be represented in many ways: Decimal system (base 10): 25 Roman numerals:

Numeral Systems. The number twenty-five 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 information

Digital Design. Assoc. Prof. Dr. Berna Örs Yalçın

Digital 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 E-mail: siddika.ors@itu.edu.tr Grading 1st Midterm -

More information

Decimal to Binary Conversion

Decimal 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 information

CS101 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 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 information

Unit 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. Unit 1 Number Sense In this unit, students will study repeating decimals, percents, fractions, decimals, and proportions. BLM Three Types of Percent Problems (p L-34) is a summary BLM for the material

More information

Chapter 7 Lab - Decimal, Binary, Octal, Hexadecimal Numbering Systems

Chapter 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 information

Numeration systems. Resources and methods for learning about these subjects (list a few here, in preparation for your research):

Numeration 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 information

Machine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.

Machine 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 information

The Hexadecimal Number System and Memory Addressing

The 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 information

Solution for Homework 2

Solution 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 information

BINARY CODED DECIMAL: B.C.D.

BINARY 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 information

Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit

Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit Decimal Division Remember 4th grade long division? 43 // quotient 12 521 // divisor dividend -480 41-36 5 // remainder Shift divisor left (multiply by 10) until MSB lines up with dividend s Repeat until

More information

CS201: Architecture and Assembly Language

CS201: 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 information

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

1. 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 information

Grade 6 Math Circles. Binary and Beyond

Grade 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 information

Addition Methods. Methods Jottings Expanded Compact Examples 8 + 7 = 15

Addition 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 information

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

A 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. Accumulator-based 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 information

COMBINATIONAL CIRCUITS

COMBINATIONAL 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 information

Computers. Hardware. The Central Processing Unit (CPU) CMPT 125: Lecture 1: Understanding the Computer

Computers. Hardware. The Central Processing Unit (CPU) CMPT 125: Lecture 1: Understanding the Computer Computers CMPT 125: Lecture 1: Understanding the Computer Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University January 3, 2009 A computer performs 2 basic functions: 1.

More information

Management Challenge. Managing Hardware Assets. Central Processing Unit. What is a Computer System?

Management 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 information

Positional Numbering System

Positional 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 information

Decimals and other fractions

Decimals 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 information

Decimal Number (base 10) Binary Number (base 2)

Decimal 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 information

Lecture 8: Binary Multiplication & Division

Lecture 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 information

PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 TUTORIAL OUTCOME 2 Part 1

PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 TUTORIAL OUTCOME 2 Part 1 UNIT 22: PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 TUTORIAL OUTCOME 2 Part 1 This work covers part of outcome 2 of the Edexcel standard module. The material is

More information

DIGITAL-TO-ANALOGUE AND ANALOGUE-TO-DIGITAL CONVERSION

DIGITAL-TO-ANALOGUE AND ANALOGUE-TO-DIGITAL CONVERSION DIGITAL-TO-ANALOGUE AND ANALOGUE-TO-DIGITAL CONVERSION Introduction The outputs from sensors and communications receivers are analogue signals that have continuously varying amplitudes. In many systems

More information

The Answer to the 14 Most Frequently Asked Modbus Questions

The Answer to the 14 Most Frequently Asked Modbus Questions Modbus Frequently Asked Questions WP-34-REV0-0609-1/7 The Answer to the 14 Most Frequently Asked Modbus Questions Exactly what is Modbus? Modbus is an open serial communications protocol widely used in

More information

NUMBER SYSTEMS APPENDIX D. You will learn about the following in this appendix:

NUMBER SYSTEMS APPENDIX D. You will learn about the following in this appendix: APPENDIX D NUMBER SYSTEMS You will learn about the following in this appendix: The four important number systems in computing binary, octal, decimal, and hexadecimal. A number system converter program

More information

Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1 Divide: Paper & Pencil Computer Architecture ALU Design : Division and Floating Point 1001 Quotient Divisor 1000 1001010 Dividend 1000 10 101 1010 1000 10 (or Modulo result) See how big a number can be

More information

Copyright 2012 Pearson Education, Inc. Chapter 1 INTRODUCTION TO COMPUTING AND ENGINEERING PROBLEM SOLVING

Copyright 2012 Pearson Education, Inc. Chapter 1 INTRODUCTION TO COMPUTING AND ENGINEERING PROBLEM SOLVING Chapter 1 INTRODUCTION TO COMPUTING AND ENGINEERING PROBLEM SOLVING Outline Objectives 1. Historical Perspective 2. Recent Engineering Achievements 3. Computing Systems 4. Data Representation and Storage

More information

6 The Hindu-Arabic System (800 BC)

6 The Hindu-Arabic System (800 BC) 6 The Hindu-Arabic System (800 BC) Today the most universally used system of numeration is the Hindu-Arabic system, also known as the decimal system or base ten system. The system was named for the Indian

More information

CHAPTER 3 Boolean Algebra and Digital Logic

CHAPTER 3 Boolean Algebra and Digital Logic CHAPTER 3 Boolean Algebra and Digital Logic 3.1 Introduction 121 3.2 Boolean Algebra 122 3.2.1 Boolean Expressions 123 3.2.2 Boolean Identities 124 3.2.3 Simplification of Boolean Expressions 126 3.2.4

More information

Session 7 Fractions and Decimals

Session 7 Fractions and Decimals Key Terms in This Session Session 7 Fractions and Decimals Previously Introduced prime number rational numbers New in This Session period repeating decimal terminating decimal Introduction In this session,

More information

This Unit: Floating Point Arithmetic. CIS 371 Computer Organization and Design. Readings. Floating Point (FP) Numbers

This Unit: Floating Point Arithmetic. CIS 371 Computer Organization and Design. Readings. Floating Point (FP) Numbers This Unit: Floating Point Arithmetic CIS 371 Computer Organization and Design Unit 7: Floating Point App App App System software Mem CPU I/O Formats Precision and range IEEE 754 standard Operations Addition

More information

BCD (ASCII) Arithmetic. Where and Why is BCD used? Packed BCD, ASCII, Unpacked BCD. BCD Adjustment Instructions AAA. Example

BCD (ASCII) Arithmetic. Where and Why is BCD used? Packed BCD, ASCII, Unpacked BCD. BCD Adjustment Instructions AAA. Example BCD (ASCII) Arithmetic We will first look at unpacked BCD which means strings that look like '4567'. Bytes then look like 34h 35h 36h 37h OR: 04h 05h 06h 07h x86 processors also have instructions for packed

More information

Encoding Text with a Small Alphabet

Encoding Text with a Small Alphabet Chapter 2 Encoding Text with a Small Alphabet Given the nature of the Internet, we can break the process of understanding how information is transmitted into two components. First, we have to figure out

More information

Let s put together a Manual Processor

Let s put together a Manual Processor Lecture 14 Let s put together a Manual Processor Hardware Lecture 14 Slide 1 The processor Inside every computer there is at least one processor which can take an instruction, some operands and produce

More information

Binary Number System. 16. Binary Numbers. Base 10 digits: 0 1 2 3 4 5 6 7 8 9. Base 2 digits: 0 1

Binary Number System. 16. Binary Numbers. Base 10 digits: 0 1 2 3 4 5 6 7 8 9. Base 2 digits: 0 1 Binary Number System 1 Base 10 digits: 0 1 2 3 4 5 6 7 8 9 Base 2 digits: 0 1 Recall that in base 10, the digits of a number are just coefficients of powers of the base (10): 417 = 4 * 10 2 + 1 * 10 1

More information

Computer Science PLUS I Volume 1 : Concepts Government of Tamilnadu

Computer Science PLUS I Volume 1 : Concepts Government of Tamilnadu Computer Science PLUS I Volume 1 : Concepts Government of Tamilnadu Government of Tamilnadu First Edition 2005 Chairman Syllabus Committee Dr. Balagurusamy E, Vice Chancellor, Anna University, Chennai

More information

COMPSCI 210. Binary Fractions. Agenda & Reading

COMPSCI 210. Binary Fractions. Agenda & Reading COMPSCI 21 Binary Fractions Agenda & Reading Topics: Fractions Binary Octal Hexadecimal Binary -> Octal, Hex Octal -> Binary, Hex Decimal -> Octal, Hex Hex -> Binary, Octal Animation: BinFrac.htm Example

More information

Multiplying and Dividing Signed Numbers. Finding the Product of Two Signed Numbers. (a) (3)( 4) ( 4) ( 4) ( 4) 12 (b) (4)( 5) ( 5) ( 5) ( 5) ( 5) 20

Multiplying and Dividing Signed Numbers. Finding the Product of Two Signed Numbers. (a) (3)( 4) ( 4) ( 4) ( 4) 12 (b) (4)( 5) ( 5) ( 5) ( 5) ( 5) 20 SECTION.4 Multiplying and Dividing Signed Numbers.4 OBJECTIVES 1. Multiply signed numbers 2. Use the commutative property of multiplication 3. Use the associative property of multiplication 4. Divide signed

More information

26 Integers: Multiplication, Division, and Order

26 Integers: Multiplication, Division, and Order 26 Integers: Multiplication, Division, and Order Integer multiplication and division are extensions of whole number multiplication and division. In multiplying and dividing integers, the one new issue

More information

Count the Dots Binary Numbers

Count the Dots Binary Numbers Activity 1 Count the Dots Binary Numbers Summary Data in computers is stored and transmitted as a series of zeros and ones. How can we represent words and numbers using just these two symbols? Curriculum

More information

We can express this in decimal notation (in contrast to the underline notation we have been using) as follows: 9081 + 900b + 90c = 9001 + 100c + 10b

We can express this in decimal notation (in contrast to the underline notation we have been using) as follows: 9081 + 900b + 90c = 9001 + 100c + 10b In this session, we ll learn how to solve problems related to place value. This is one of the fundamental concepts in arithmetic, something every elementary and middle school mathematics teacher should

More information

Chapter 1. Binary, octal and hexadecimal numbers

Chapter 1. Binary, octal and hexadecimal numbers Chapter 1. Binary, octal and hexadecimal numbers This material is covered in the books: Nelson Magor Cooke et al, Basic mathematics for electronics (7th edition), Glencoe, Lake Forest, Ill., 1992. [Hamilton

More information

Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language

Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language Chapter 4 Register Transfer and Microoperations Section 4.1 Register Transfer Language Digital systems are composed of modules that are constructed from digital components, such as registers, decoders,

More information

1. Convert the following base 10 numbers into 8-bit 2 s complement notation 0, -1, -12

1. Convert the following base 10 numbers into 8-bit 2 s complement notation 0, -1, -12 C5 Solutions 1. Convert the following base 10 numbers into 8-bit 2 s complement notation 0, -1, -12 To Compute 0 0 = 00000000 To Compute 1 Step 1. Convert 1 to binary 00000001 Step 2. Flip the bits 11111110

More information

Chapter 2 Logic Gates and Introduction to Computer Architecture

Chapter 2 Logic Gates and Introduction to Computer Architecture Chapter 2 Logic Gates and Introduction to Computer Architecture 2.1 Introduction The basic components of an Integrated Circuit (IC) is logic gates which made of transistors, in digital system there are

More information

What Is Singapore Math?

What Is Singapore Math? What Is Singapore Math? You may be wondering what Singapore Math is all about, and with good reason. This is a totally new kind of math for you and your child. What you may not know is that Singapore has

More information

Lecture N -1- PHYS 3330. Microcontrollers

Lecture N -1- PHYS 3330. Microcontrollers Lecture N -1- PHYS 3330 Microcontrollers If you need more than a handful of logic gates to accomplish the task at hand, you likely should use a microcontroller instead of discrete logic gates 1. Microcontrollers

More information

Comp 255Q - 1M: Computer Organization Lab #3 - Machine Language Programs for the PDP-8

Comp 255Q - 1M: Computer Organization Lab #3 - Machine Language Programs for the PDP-8 Comp 255Q - 1M: Computer Organization Lab #3 - Machine Language Programs for the PDP-8 January 22, 2013 Name: Grade /10 Introduction: In this lab you will write, test, and execute a number of simple PDP-8

More information

Chapter 6. Inside the System Unit. What You Will Learn... Computers Are Your Future. What You Will Learn... Describing Hardware Performance

Chapter 6. Inside the System Unit. What You Will Learn... Computers Are Your Future. What You Will Learn... Describing Hardware Performance What You Will Learn... Computers Are Your Future Chapter 6 Understand how computers represent data Understand the measurements used to describe data transfer rates and data storage capacity List the components

More information