Chapter 3 DATA REPRESENTATION. 3.1 Character Representation
|
|
- Mervin Price
- 7 years ago
- Views:
Transcription
1 Chapter 3 DATA REPRESENTATION Binary codes are used to represent both characters and numbers inside computers. Moreover, the binary codes used to represent numbers must be consistent with the arithmetic operations on those numbers: by performing an arithmetic operation on the codes of two numbers, we must obtain the code of the result of that operation on the numbers. Also, by their nature, computers can only represent quantities having a finite number of bits. Therefore, only a finite number of integers can be represented inside a digital computer system. One of these integers is the largest value, and another one the smallest one. This chapter describes the different binary codes used to represent characters and signed integers. It also discusses the limits imposed by these representations, and examines arithmetic operations on these numbers, and how errors occur. 3.1 Character Representation The two major codes used to represent characters inside digital computers are the EBCDIC (extended binary-coded decimal information code) and the ASCII (american standard code for information interchange) codes. The EBCDIC code is used in IBM 360/370 mainframe systems, whereas the ASCII code is used in most computers, including computer systems based on Intel processors. 53
2 54 With these codes, a character is represented by an 8-bit (two hexadecimal digits) code, and a character string is represented by a sequence of bits consisting of the codes of the individual characters in the string. For example, the string "CS-280" is represented in ASCII by the sequence of hexadecimal digits 43532D323830h, where 43h is the ASCII code of the character C, 53h the code of S, 2Dh the code of -, 32h the code of 2', 38h the code of 8', and 30h the code of 0'. Although the ASCII code is an 8-bit code, only the right-most seven bits 7 are used to encode information. It then follows that only 128 (2 ) characters can be encoded. Using all 8 bits to encode information makes it possible to 8 represent 256 (2 ) characters. This extension of the ASCII code is used on computers with Intel processors and is referred to as the Extended ASCII code. The ASCII code is provided in appendix 1. It consists of the control codes that are used as signals to control the different components of the computer, and the codes for the printable characters (that means characters that may be displayed on the screen or sent to the printer). 7 8 With only 128 (2 ) character codes for the ASCII code and 256 (2 ) character codes for the Extended ASCII code, the requirements of many languages such as the Japanese language could not be met. Therefore, certain computer industry companies are suggesting a new 16-bit code called 16 Unicode. The 16-bit Unicode has 65,536 (2 ) character codes, making it possible to represent the alphabet of most languages of the world. Exercise 3.1 Part I 1. What are the two major codes that are used to represent characters in most computers today? 2. ASCII stands for:. 3. EBCDIC stands for:. 4. What is the code that is used to represent characters on IBM PC and compatible computers? 5. How many characters are represented in ASCII code?
3 55 6. How many characters are represented in Extended ASCII code? 7. What is the difference between the ASCII code and the Extended ASCII code? 8. How many characters are represented in unicode? Part II Provide the ASCII code representation of each of the following sequences of characters: a. CS-280 b. Mark s tape c d. Two_Flags 3.2 Numeric Data Three types of numbers are represented inside most digital computer systems: binary integers, binary-coded decimal (BCD), and floating-point numbers. Binary integers use a fixed number of bits to represent signed and unsigned integers. Binary-coded decimal numbers allow for a greater range of values than binary integers, and for the representation of an implicit decimal point, whereas floating-point numbers are used to approximate real numbers. This chapter discusses the representation of binary integers. Unsigned and signed binary integers are represented inside a digital computer by a fixed number of bits. The number of bits used on most computers are 8, 16, 32, and 64 bits. Unsigned integers are used to represent zero and positive integer values in base 2. For example the 8-bit unsigned integers represent integers values 8 in the range 0 to 511 (2-1 ) and the 16-bit unsigned integers represent 16 integer values in the range 0 to 65,535 (2-1 ). The two encoding methods suggested for the representation of signed integers are the sign-magnitude and the two's complement. But most computers, including computer with Intel processors use the two s complement representation.
4 56 Sign-Magnitude Number Systems In n-bit sign-magnitude number system, a signed integer is represented as: s b n-2 b n-3... b 2 b 1 b 0 where b n-2 b n-3... b 2 b 1 b 0 is the magnitude (absolute value) of the number in base 2 and s is 0 if the number is positive, and 1 if it is negative. s is referred to as the sign bit. This representation is illustrated in Example 3.1. Example 3.1 Conversion of Decimal Integers to Sign-Magnitude Number Systems Convert to 8-bit sign-magnitude number system the decimal integers 6, -10, 47, 127 and = = 06h -10 = = 8Ah 47 = = 2Fh 127 = = 7Fh -127 = = FFh Observe that 128 and -128 can not be represented in 8-bit sign-magnitude number system. In general, the range of values that can be represented in n-bit sign magnitude is - n-1 n-1 (2-1) to 2-1. This representation uses n-1 bits to represent the absolute value of an n-1 integer, with the largest absolute value being the decimal value 2-1. So, in 16-bit sign magnitude, only the integer values in the range = -32,767 to 2-1 = 32,767 can be represented. The rules for sign-magnitude addition are the same that we use for decimal integer addition:
5 57 1. If the signs of the two numbers are the same, add the two magnitudes, and attach the common sign. 2. If the signs of the two numbers are different, then subtract the smaller magnitude from the larger one to obtain the magnitude of the result. The sign of the result is the sign of the number having the larger magnitude. So, in 8-bit sign-magnitude, is = = 2 and, -6 + (-8) is = = -14. Overflow in a Sign-Magnitude Number System An overflow occurs when the result of a computation falls outside of the range of a number system. In n-bit sign-magnitude, this is the case when the magnitude of the result has more than n-1 bits. For example, the following addition of 8-bit sign-magnitude integers generates an overflow condition: = The last carry does not affect the sign bit; it is lost and the result is erroneously Note that an overflow condition can not be generated when both operands of an addition operation have opposite signs. Disadvantages of the Sign-Magnitude Number System There are two major drawbacks to the sign-magnitude representation of integers: First, there are two representation of 0: +0 = and -0 = Second, the addition of integers requires either the addition or the subtraction of the magnitudes, depending on the signs of the operands. Therefore, in addition to providing a circuit that performs addition, the computer manufacturer must also provide a circuit to perform subtractions. However, this additional circuit is not necessary for other integer representations such as the two s complement representation described bellow.
6 58 Exercise Convert the following decimal integers to 8-bit sign-magnitude number system: a. 56 b. -27 c. 18 d Perform the following operations on 8-bit sign-magnitude integers and also indicate whether or not there is an overflow condition: a b c d e f What are the two major disadvantages of the sign-magnitude number systems? Two's Complement Binary Number Systems n In n-bit two s complement binary number system, 2 n-bit codes are used to represent positive and negative integers as follows: n-1 n-1! the binary representation of 2 using n bits is used to represent -2! the binary representation (using n bits) of 0 or any positive integer n-1 less than 2 is used to represent that integer n-1! for each positive integer m less than 2 with n-bit code d, the n-bit n code that represents -m is 2 - d. It follows from the above description that in n-bit two s complement binary number system, we have the following conditions: n-1 a) only the positive integers less than 2 can be represented. Morever, a positive integer is represented by its binary representation using n bits. n-1 b) the smallest negative integer that can be represented is -2. It is n-1 represented by the binary representation (using n bits) of 2.
7 59 c) if d is the n-bit code that represents a positive integer m, then the n-bit n code that represents -m is 2 - d. Table 3.1 illustrates the representations of 8 and 16-bit two s complement binary integers. The range of negative and positive decimal integers that can be n-1 n-1 represented in n-bit two s complement number system is -2 to 2-1. For example, in 8-bit two s complement number system, the range of decimal 7 7 integers is -2 = to 2-1 = 127, and in 16-bit the range of decimal integers is -2 = -32,768 to 2-1 = 32,767. Computers with the Intel 8086 processor represent integers in two's complement binary number system using 8, 16, and 32 bits. In these computers, 8, 16, and 32-bit two's complement binary integers are usually referred to as short integers, integers and long integers respectively, in some high-level languages. Exercise 3.3 Provide the 3-bit two s complement binary representation of integers. Taking the Two s Complement n The two s complement of an n-bit integer d is to 2 - d. For example, the two s complement of the 8-bit integer is computed as follows: d Two s complement of d
8 60 Table 3.1 Range of 8-bit and 16-bit Two s Complement Binary Integers Decimal Integers 8-Bit Binary Integers 16-Bit Binary Integers 15-2 = -32, = -32, = -32, = FF7F 7-2 = FF = FF81-2 FE = FFFE = 10000h FF = 100h - 1 FFFF = 10000h = 127 7F 007F 7 2 = = 32,767. 7FFF
9 61 n n n Note that 2 - d = (2-1) - d + 1 and (2-1) is an n-bit integer consisting of 1's. Therefore, the two s complement of the 8-bit integer above can also be computed as follows: d Two s complement of d In hexadecimal, it is computed as follows: FF - 0B F4 + 1 F5 Observe that subtracting a bit value from 1 is the same thing as inverting that bit value. That means, if it is 1, change it to 0; and if it is 0, change it to 1. The two s complement of an n-bit integer may then be computed by applying the following two rules, Rule 3.1.a and Rule 3.1.b. Rule 3.1.a applies when the integer is in binary, and Rule 3.1.b applies when it is in hexadecimal. Rule 3.1. a To compute the two s complement of an n-bit integer, do the following: 1. Invert each bit value (the result is called the one s complement) 2. Add 1 to the one s complement.
10 62 Rule 3.1. b To compute the two s complement of an hexadecimal integer, do the following: 1. Subtract each hexadecimal digit from F (the result is called the one s complement) 2. Add 1 to the one s complement. These rules are illustrated in Example 3.2. You may notice in this example that the two s complement of C6h is 3Ah and the two s complement of 3Ah is C6h. This is because, by taking the two s complement twice, you obtain n n n n the original number: 2 - (2 - d) = d = d. However, if d is the n-1 n-bit two s complement binary code that represents -2, then the two s complement of d is d. For example, the two s complement of 80h is 80h, and the two s complement of 8000h is 8000h. Example 3.2 Computing the Two s complement Compute the two s complement of the following binary/hexadecimal integers: a b c. 3Ah d. C6h Solutions a. b d d invert bit values invert bit values + 1 add add s complement s complement
11 63 c. d. F F F F - 3 A d - C 6 d C 5 1's complement 3 9 1's complement + 1 add add 1 C 6 2's complement 3 A 2's complement Notice that the two s complement of C6h is 3Ah, and that the two s complement of 3Ah is C6h. Exercise Compute the two s complement of the following 8-bit integers: a b c Compute the two s complement of the following 16-bit (hexadecimal) integers: a. 1A35h b. E50Ch c. FF0A Conversion from Decimal to Two s Complement It is important not to confuse the process of taking the two s complement of a binary or an hexadecimal integer with the two s complement binary number system: a two s complement binary integer is a number in the two s complement binary number system. However, when you take the two s complement of a binary integer, you are performing an arithmetic operation. The following rule to convert a decimal integer to two s complement binary system is based on the description of the two s complement binary number system provided above.
12 64 Rule 3.2 To convert a decimal integer to n-bit two s complement binary number system, do the following: a. If the number is positive, convert it to base 2 (or hexadecimal) using n bits. b. If the number is negative: 3. Convert its magnitude (absolute value) to base 2 (or hexadecimal) using n bits. 4. Take its two s complement. This rule is illustrated in Example 3.3. Example 3.3 Conversion from decimal to two s complement binary integers Convert the following decimal integers to 8-bit two s complement binary integer : a. 10 b. 47 c. 127 d. -10 e. -47 f Solutions a. 10 = = 0Ah b. 47 = = 2Fh c. 127 = = 7Fh d. 10 = 0A the two s complement of 0A = FF - 0A + 1 = F6 Therefore, -10 = F6h e. 47 = 2F the two s complement of 2F = FF - 2F + 1 = D1 Therefore, -47 = D1h f. 127 = 7F Two s complement of 7F = FF - 7F + 1 = 81 Therefore, -127 = 81h
13 65 Exercise 3.5 Convert the following decimal integers to 16-bit two s complement binary integer, but specify your answers in hexadecimal. a. 27 b. -35 c. 129 d. -87 e Sign Bit of a Two s Complement Binary Integer The sign bit of a two's complement binary integer is its left-most bit. It is 0 for a positive integer and 1 for a negative integer. Therefore, since the hexadecimal digits 8, 9, A, B, C, D, E, and F all have their left-most bit 1 in binary, and 0, 1, 2, 3, 4, 5, 6, and 7 all have their left-most bit 0, a two s complement binary integer represented in hexadecimal is negative if its leftmost digit is 8, 9, A, B, C, D, E or F; and positive if its left-most digit is 0, 1, 2, 3, 4, 5, 6, or 7. Conversion from Two's Complement to Decimal We have seen above that if you take the two s complement twice, you obtain the original number. For example, if you take the two s complement of D1h (which represents the decimal integer -47), you get back 2Fh (which represents the decimal integer 47). We therefore have the following rule to convert from two s complement binary number system to decimal. Rule 3.3 To convert a two s complement binary integer to decimal, do the following: a. If it is positive (its left-most bit is 0) convert it to decimal as if it were an unsigned integer in base 2 (or base 16).
14 66 b. If it is negative (its left-most bit is 1), do the following: i) take its two s complement ii) convert the result in i) above to decimal as if it were an unsigned integer in base 2 (or base 16). iii) add the minus sign to the result in ii) above. This rule is illustrated in Example 3.4. Example 3.4 Conversion from Two s Complement Binary Integers to Decimal Convert the following 16-bit two's complement binary integers to decimal: a. 6A0Fh b. F0F1h c. 8A00h d. 501Eh Solutions a. 6A0Fh is positive: convert it to decimal as if it is a binary/hexadecimal integer: therefore, 6A0Fh = 24, = 27,151 (in decimal) b. F0F1h is negative: i) take its two s complement: FFFF - F0F1 + 1 = 0F0F ii) convert to decimal: 0F0Fh = = 3855 iii) append the minus sign: F0F1h = (in decimal) c. 8A00h is negative: i) take its two's complement: FFFF - 8A = 7600 ii) convert it to decimal: 7600h = 28, = 30,208 iii) append the minus sign: 8A00h = -30,208 (in decimal) d. 501Eh is positive: convert it to decimal as if it is a binary/hexadecimal integer: therefore, 501Eh = 20, = 20,510 (in decimal)
15 67 Exercise 3.6 Convert the following 8 and 16-bit two's complement binary integers to decimal: a. 5A b. F5 c. 102A d. E52D Addition of Two's Complement Binary Integers You add n-bit two's complement binary integers the same way you add unsigned integers in base 2 (or hexadecimal), without any concern about the signs or the relative size of the magnitudes. However, the result of the addition must also be an n-bit integer: any carry out of the left-most bit (or left-most hexadecimal digit) is lost without affecting the result of the operation. Example 3.5 illustrates the addition of integers represented in both the decimal and 16-bit two s complement binary number system. In Example 3.5 c. and 3.5 f., notice that the additive inverse of a two s complement binary integer is its two s complement: by taking the two s complement of a two s complement binary integer, and then adding the result to that integer, you obtain the representation of zero. Example 3.5 Addition of Two s Complement Binary Integers Decimal Two s complement a A c F F F B b F F F F Decimal Binary Integer d F F F D -1 F F F F
16 68 e. -5 F F F B F F F F -6 F F F A f. -20 F F E C Exercise 3.7 Perform the following operations on 8 and 16-bit two s complement integers: a. 1 C b. B 9 c. F F 4 C d. 1 B 2 A e. 7 A 3 D + B 3 + F E B 2 Subtracting Two s Complement Binary Integers To subtract a two's complement binary integer, first take its two s complement, and then add the result of this operation. Example 3.6 illustrates the subtraction of integers represented in decimal and in 16-bit two s complement binary number system.
17 69 Example 3.6 Subtracting Two s Complement Binary Integers Decimal Two s complement a F F F A E b F F F F c. -5 F F F B F F F B F F F B Exercise 3.8 Perform the following operations on 8 and 16-bit two s complement integers: a. A 5 b. 8 A - E F - 0 B c D d. 3 7 A F - E 8 F B A
18 70 Overflow in a Two s Complement Number System The addition/subtraction of n-bit two s complement binary integers generates an overflow when the result can not be represented using n bits. As you may notice in Example 3.5 b., 3.5 c., 3.5 e., and 3.5 f., an overflow does not necessary occur when there is a carry out of the left-most bit (or hexadecimal digit). As with the sign-magnitude notation, An overflow may not occur when you add values with opposite signs: an overflow occurs only when you add two values with the same sign, but the result of the operation has a different sign. Example 3.7 illustrates some addition operations that generate an overflow. Example 3.7 Overflow Condition The following addition operations on two s complement binary integers generate an overflow. a (pos.) b. 7 0 A 5 (pos.) c (neg.) + 7 F F F (pos.) + 5 A 2 0 (pos.) + F F F F (neg.) (neg.) C A C 5 (neg.) 7 F F F (pos.) Exercise 3.9 Indicate whether or not each operation in Exercise 3.7 and Exercise 3.8 generates an overflow.
19 Conversion between 8, 16, and 32-bit Two's Complement Integers 71 An 8-bit two's complement binary integer can be represented using 16 bits, and a 16-bit two s complement binary integer can also be represented using 32 bits. However, some 32-bit two s complement binary integers can not be represented using 16 bits, and some 16-bit two s complement binary integers can not be represented using 8 bits. In a positional number system such as decimal, binary or hexadecimal, you do not change the value of an unsigned integer by adding as many zeros as you want to its left. Similarly, you do not change the value of a two s complement binary integer by adding its sign bit to its left as many times as you want. Therefore, you convert an 8-bit two s complement binary integer to 16 bits, by expanding its sign bit to the 8 extra bit positions to the left; and you convert a 16-bit two s complement binary integer to 32 bits, by expanding its sign bit to the 16 extra bit positions to the left. You convert a 32-bit two's complement binary integer to 16 bits by taking its lower 16 bits; and you convert a 16-bit two s complement binary integer to 8 bits by taking its lower 8 bits. However, this conversion will produce an incorrect result if the 32-bit integer can not be represented using 16 bits, or the 16-bit integer can not be represented using 8 bits. This is the case when the higher 16 bits of the 32-bit integer, or the higher 8 bits of the 16-it integer are not its sign bit. Example 3.8 illustrates the representation of certain integers in 8, 16, and 32-bit two s complement number system. A dash indicates that the integer can not be represented using 8 or 16 bits. Invalid conversions from 16-bit to 8-bit two s complement binary integers are illustrated in Example 3.9.
20 72 Example 3.8 Representations of Integers in Decimal, 8, 16, and 32-bit two s Complement Number System Decimal 8-Bit 16-Bit 32-Bit 106 6A 006A A FF92 FFFFFF92-1 FF FFFF FFFFFFFF FF80 FFFFFF FF7E FFFFFF7E Notice that 128 and -130 can not be represented in 8-bit two s complement number system. Example 3.9 Invalid Conversions from 16-bit to 8-bit Two s Complement Integers 16-Bit 8-Bit Comments 5A6B 6B the sign bit of 6B corresponds to 00 5A F0F5 F5 the sign bit of F5 corresponds to FF F the sign bit of 85 corresponds to FF 00 FF61 61 the sign bit of 61 corresponds to 00 FF
21 73 Exercise Convert the following 8-bit two s complement binary integers to 16 bits: a. F8 b. 6F c. 82 d. 39 e. AD 2. Convert the following 16-bit two s complement binary integers to 8 bits, and also indicate whether the conversion is correct or not: a. FF87 b. 006F c. FF7B d e. 7A52
22 74 Chapter 3: Exercises 1. Provide the ASCII code representation of each of the following strings of characters: a. Math-160 b. CS_345 c. John Doe 2. Convert the following decimal integers to 16-bit two s complement number system: a. 49 d. -32 g. 304 j b. -15 e. -19 h. 310 k c. 65 f i Convert the following two s complement binary integers to decimal: a. 3A50 c. 7F0A e. 49A2 g. 7E b. FFA9 d. F6 f. 85 h. 9F 4. Perform the following operations on two s complement binary integers and also indicate whether or not there is an overflow condition: a. FA + 5F d. FFA A g E5 b. 7E + 24 e. 85A6 + A5B0 h. 5A90-32F5 c. 3A B6 f. 2A - 3B i. 9AF6-000A j. 7FFF - 800A 5. Convert the following 8-bit two s complement binary integers to 16 bits: a. 74 b. F5 c. 6A d. 9B e. A0 f Convert the following 16-bit two s complement binary integers to 8 bits and also indicate whether or not the conversion is correct: a. FF95 b. 7A2F c. 6B5C d. FF5A e. 007A f. 00A5
23 75 Chapter 3: Solutions of Exercises 1. a. 4D D c. 4A 6F 68 6E F 65 b F a. 0031h d. FFE0h g. 0130h j. 0FD9h b. FFF1 e. FFEDh h. 0136h k. EBFAh c. 0041h f. FF34h i. FE6Bh 3. a. 14,928 c. 32,522 e. 18,850 g. 126 b. -87 d. -10 f h a. 59h d. 003Fh g. 9Fh j. FFF5h (ov) b. A2h (ov) e. 2B56h (ov) h. 279Bh c. 5006h f. EFh i. 9AECh 5. a. 0074h b. FFF5h c. 006Ah d. FF9Bh e. FFA0h f. 0015h 6. a. 95h (correct) c. 5Ch (incorrect) e. 7Ah (correct) b. 2Fh (incorrect) d. 5Ah (incorrect) f. A5 (incorrect)
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 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 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 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 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 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 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 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 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 (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 informationNumeral 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 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 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 informationLevent 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 informationData Storage 3.1. Foundations of Computer Science Cengage Learning
3 Data Storage 3.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List five different data types used in a computer. Describe how
More information2011, 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 informationData Storage. Chapter 3. Objectives. 3-1 Data Types. Data Inside the Computer. After studying this chapter, students should be able to:
Chapter 3 Data Storage Objectives After studying this chapter, students should be able to: List five different data types used in a computer. Describe how integers are stored in a computer. Describe how
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 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 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 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 informationBinary Numbering Systems
Binary Numbering Systems April 1997, ver. 1 Application Note 83 Introduction Binary numbering systems are used in virtually all digital systems, including digital signal processing (DSP), networking, and
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 6-3-1-1 and Excess-3? Data Representation (1/2) Each numbering
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 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 informationMACHINE INSTRUCTIONS AND PROGRAMS
CHAPTER 2 MACHINE INSTRUCTIONS AND PROGRAMS CHAPTER OBJECTIVES In this chapter you will learn about: Machine instructions and program execution, including branching and subroutine call and return operations
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 informationHOMEWORK # 2 SOLUTIO
HOMEWORK # 2 SOLUTIO Problem 1 (2 points) a. There are 313 characters in the Tamil language. If every character is to be encoded into a unique bit pattern, what is the minimum number of bits required to
More informationDigital Logic Design. Introduction
Digital Logic Design Introduction A digital computer stores data in terms of digits (numbers) and proceeds in discrete steps from one state to the next. The states of a digital computer typically involve
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 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 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. 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 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 informationThis 3-digit ASCII string could also be calculated as n = (Data[2]-0x30) +10*((Data[1]-0x30)+10*(Data[0]-0x30));
Introduction to Embedded Microcomputer Systems Lecture 5.1 2.9. Conversions ASCII to binary n = 100*(Data[0]-0x30) + 10*(Data[1]-0x30) + (Data[2]-0x30); This 3-digit ASCII string could also be calculated
More informationECE 0142 Computer Organization. Lecture 3 Floating Point Representations
ECE 0142 Computer Organization Lecture 3 Floating Point Representations 1 Floating-point arithmetic We often incur floating-point programming. Floating point greatly simplifies working with large (e.g.,
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 informationZ80 Instruction Set. Z80 Assembly Language
75 Z80 Assembly Language The assembly language allows the user to write a program without concern for memory addresses or machine instruction formats. It uses symbolic addresses to identify memory locations
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 informationIntel Hexadecimal Object File Format Specification Revision A, 1/6/88
Intel Hexadecimal Object File Format Specification Revision A, 1/6/88 DISCLAIMER Intel makes no representation or warranties with respect to the contents hereof and specifically disclaims any implied warranties
More informationBCD (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 informationDivide: 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 information2010/9/19. Binary number system. Binary numbers. Outline. Binary to decimal
2/9/9 Binary number system Computer (electronic) systems prefer binary numbers Binary number: represent a number in base-2 Binary numbers 2 3 + 7 + 5 Some terminology Bit: a binary digit ( or ) Hexadecimal
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 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 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 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 E-mail: siddika.ors@itu.edu.tr Grading 1st Midterm -
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 informationHexadecimal Object File Format Specification
Hexadecimal Object File Format Specification Revision A January 6, 1988 This specification is provided "as is" with no warranties whatsoever, including any warranty of merchantability, noninfringement,
More informationEncoding 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 informationDNA Data and Program Representation. Alexandre David 1.2.05 adavid@cs.aau.dk
DNA Data and Program Representation Alexandre David 1.2.05 adavid@cs.aau.dk Introduction Very important to understand how data is represented. operations limits precision Digital logic built on 2-valued
More informationThis 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 informationThe 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 informationCounting 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 informationComputers. 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 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 information1. 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 informationBachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)
Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating
More informationUnpacked BCD Arithmetic. BCD (ASCII) Arithmetic. Where and Why is BCD used? From the SQL Server Manual. Packed BCD, ASCII, Unpacked BCD
BCD (ASCII) Arithmetic The Intel Instruction set can handle both packed (two digits per byte) and unpacked BCD (one decimal digit per byte) We will first look at unpacked BCD Unpacked BCD can be either
More informationASCII and BCD Arithmetic. Chapter 11 S. Dandamudi
ASCII and BCD Arithmetic Chapter 11 S. Dandamudi Outline Representation of Numbers ASCII representation BCD representation» Unpacked BCD» Packed BCD Processing ASCII numbers» ASCII addition» ASCII subtraction»
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 informationChapter Binary, Octal, Decimal, and Hexadecimal Calculations
Chapter 5 Binary, Octal, Decimal, and Hexadecimal Calculations This calculator is capable of performing the following operations involving different number systems. Number system conversion Arithmetic
More informationAppendix C: Keyboard Scan Codes
Thi d t t d ith F M k 4 0 2 Appendix C: Keyboard Scan Codes Table 90: PC Keyboard Scan Codes (in hex) Key Down Up Key Down Up Key Down Up Key Down Up Esc 1 81 [ { 1A 9A, < 33 B3 center 4C CC 1! 2 82 ]
More informationAppendix A Installation of Visual C++ and MASM
Appendix A Installation of Visual C++ and MASM If your college, university, or company already has Visual C++ and MASM installed, then their procedures should be consulted and the information contained
More informationASCII Characters. 146 CHAPTER 3 Information Representation. The sign bit is 1, so the number is negative. Converting to decimal gives
146 CHAPTER 3 Information Representation The sign bit is 1, so the number is negative. Converting to decimal gives 37A (hex) = 134 (dec) Notice that the hexadecimal number is not written with a negative
More informationThe use of binary codes to represent characters
The use of binary codes to represent characters Teacher s Notes Lesson Plan x Length 60 mins Specification Link 2.1.4/hi Character Learning objective (a) Explain the use of binary codes to represent characters
More information2 ASCII TABLE (DOS) 3 ASCII TABLE (Window)
1 ASCII TABLE 2 ASCII TABLE (DOS) 3 ASCII TABLE (Window) 4 Keyboard Codes The Diagram below shows the codes that are returned when a key is pressed. For example, pressing a would return 0x61. If it is
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 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 informationSection 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 informationASCII Code. Numerous codes were invented, including Émile Baudot's code (known as Baudot
ASCII Code Data coding Morse code was the first code used for long-distance communication. Samuel F.B. Morse invented it in 1844. This code is made up of dots and dashes (a sort of binary code). It was
More informationMEP Y9 Practice Book A
1 Base Arithmetic 1.1 Binary Numbers We normally work with numbers in base 10. In this section we consider numbers in base 2, often called binary numbers. In base 10 we use the digits 0, 1, 2, 3, 4, 5,
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 informationM6800. Assembly Language Programming
M6800 Assembly Language Programming 1 3. MC6802 MICROPROCESSOR MC6802 microprocessor runs in 1MHz clock cycle. It has 64 Kbyte memory address capacity using 16-bit addressing path (A0-A15). The 8-bit data
More informationBinary 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 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 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 informationThe x86 PC: Assembly Language, Design, and Interfacing 5 th Edition
Online Instructor s Manual to accompany The x86 PC: Assembly Language, Design, and Interfacing 5 th Edition Muhammad Ali Mazidi Janice Gillispie Mazidi Danny Causey Prentice Hall Boston Columbus Indianapolis
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 informationMICROPROCESSOR AND MICROCOMPUTER BASICS
Introduction MICROPROCESSOR AND MICROCOMPUTER BASICS At present there are many types and sizes of computers available. These computers are designed and constructed based on digital and Integrated Circuit
More informationI PUC - Computer Science. Practical s Syllabus. Contents
I PUC - Computer Science Practical s Syllabus Contents Topics 1 Overview Of a Computer 1.1 Introduction 1.2 Functional Components of a computer (Working of each unit) 1.3 Evolution Of Computers 1.4 Generations
More informationAN1304. NFC Type MIFARE Classic Tag Operation. Application note PUBLIC. Rev. 1.3 2 October 2012 130413. Document information
NFC Type MIFARE Classic Tag Operation Document information Info Content Keywords NDEF, NDEF data mapping, NDEF Data Exchange Format MIFARE Classic 1K, MIFARE Classic 4K, MIFARE Classic 1K/4K, MIFARE Plus
More informationToday s topics. Digital Computers. More on binary. Binary Digits (Bits)
Today s topics! Binary Numbers! Brookshear.-.! Slides from Prof. Marti Hearst of UC Berkeley SIMS! Upcoming! Networks Interactive Introduction to Graph Theory http://www.utm.edu/cgi-bin/caldwell/tutor/departments/math/graph/intro
More informationProgrammer s Reference
Programmer s Reference 1 Introduction This manual describes Launchpad s MIDI communication format. This is all the proprietary information you need to be able to write patches and applications that are
More informationFaculty of Engineering Student Number:
Philadelphia University Student Name: Faculty of Engineering Student Number: Dept. of Computer Engineering Final Exam, First Semester: 2012/2013 Course Title: Microprocessors Date: 17/01//2013 Course No:
More informationCPU Organization and Assembly Language
COS 140 Foundations of Computer Science School of Computing and Information Science University of Maine October 2, 2015 Outline 1 2 3 4 5 6 7 8 Homework and announcements Reading: Chapter 12 Homework:
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 informationChapter 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 informationNumerical Matrix Analysis
Numerical Matrix Analysis Lecture Notes #10 Conditioning and / Peter Blomgren, blomgren.peter@gmail.com Department of Mathematics and Statistics Dynamical Systems Group Computational Sciences Research
More informationCHAPTER 5 Round-off errors
CHAPTER 5 Round-off errors In the two previous chapters we have seen how numbers can be represented in the binary numeral system and how this is the basis for representing numbers in computers. Since any
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 informationSECTION C [short essay] [Not to exceed 120 words, Answer any SIX questions. Each question carries FOUR marks] 6 x 4=24 marks
UNIVERSITY OF KERALA First Degree Programme in Computer Applications Model Question Paper Semester I Course Code- CP 1121 Introduction to Computer Science TIME : 3 hrs Maximum Mark: 80 SECTION A [Very
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 informationCounters. Present State Next State A B A B 0 0 0 1 0 1 1 0 1 0 1 1 1 1 0 0
ounter ounters ounters are a specific type of sequential circuit. Like registers, the state, or the flip-flop values themselves, serves as the output. The output value increases by one on each clock cycle.
More informationBase 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 informationChapter 2 Basic Structure of Computers. Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan
Chapter 2 Basic Structure of Computers Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan Outline Functional Units Basic Operational Concepts Bus Structures Software
More informationInstruction Set Architecture (ISA)
Instruction Set Architecture (ISA) * Instruction set architecture of a machine fills the semantic gap between the user and the machine. * ISA serves as the starting point for the design of a new machine
More informationSistemas Digitais I LESI - 2º ano
Sistemas Digitais I LESI - 2º ano Lesson 6 - Combinational Design Practices Prof. João Miguel Fernandes (miguel@di.uminho.pt) Dept. Informática UNIVERSIDADE DO MINHO ESCOLA DE ENGENHARIA - PLDs (1) - The
More informationASSEMBLY LANGUAGE PROGRAMMING (6800) (R. Horvath, Introduction to Microprocessors, Chapter 6)
ASSEMBLY LANGUAGE PROGRAMMING (6800) (R. Horvath, Introduction to Microprocessors, Chapter 6) 1 COMPUTER LANGUAGES In order for a computer to be able to execute a program, the program must first be present
More informationArithmetic in MIPS. Objectives. Instruction. Integer arithmetic. After completing this lab you will:
6 Objectives After completing this lab you will: know how to do integer arithmetic in MIPS know how to do floating point arithmetic in MIPS know about conversion from integer to floating point and from
More informationTechnical Information. Digital Signals. 1 bit. Part 1 Fundamentals
Technical Information Digital Signals 1 1 bit Part 1 Fundamentals t Technical Information Part 1: Fundamentals Part 2: Self-operated Regulators Part 3: Control Valves Part 4: Communication Part 5: Building
More informationCOMPSCI 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