CS311-Computer OrganizationInformation RepresentationLecture 03-1 Lecture 3 Information Representation.

Slides:



Advertisements
Similar presentations
2-1 Chapter 2 - Data Representation Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer Architecture.
Advertisements

Chapter 2: Data Representation
Principles of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 2: Data Representation.
1 IEEE Floating Point Revision Guide for Phase Test Week 5.
Chapter 2 : Number System
Chapter 3 Data Representation.
Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation.
2-1 Computer Organization Part Fixed Point Numbers Using only two digits of precision for signed base 10 numbers, the range (interval between lowest.
Floating Point Numbers.  Floating point numbers are real numbers.  In Java, this just means any numbers that aren’t integers (whole numbers)  For example…
Data Representation – Chapter 3 Sections 3-2, 3-3, 3-4.
COMP201 Computer Systems Number Representation. Number Representation Introduction Number Systems Integer Representations Examples  Englander Chapter.
Dr. Bernard Chen Ph.D. University of Central Arkansas
Chapter 5 Data representation.
The Binary Number System
Data Representation Number Systems.
1 Data Representation Computer Organization Prof. H. Yoon DATA REPRESENTATION Data Types Complements Fixed Point Representations Floating Point Representations.
Data Representation – Binary Numbers
Computer Arithmetic Nizamettin AYDIN
Logic and Digital System Design - CS 303
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
1 Digital Technology and Computer Fundamentals Chapter 1 Data Representation and Numbering Systems.
IT253: Computer Organization
Computer Architecture
Dept. of Computer Science Engineering Islamic Azad University of Mashhad 1 DATA REPRESENTATION Dept. of Computer Science Engineering Islamic Azad University.
Eng. Mohammed Timraz Electronics & Communication Engineer University of Palestine Faculty of Engineering and Urban planning Software Engineering Department.
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles of Computer.
Binary Arithmetic & Data representation
Data Representation and Computer Arithmetic
Number Systems Spring Semester 2013Programming and Data Structure1.
Lecture 4: Number Systems (Chapter 3) (1) Data TypesSection3-1 (2) ComplementsSection3-2 (3) Fixed Point RepresentationsSection3-3 (4) Floating Point RepresentationsSection3-4.
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
Data Representation in Computer Systems
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
Lecture 5. Topics Sec 1.4 Representing Information as Bit Patterns Representing Text Representing Text Representing Numeric Values Representing Numeric.
CE1111 :Digital Logic Design lecture 01 Introduction Dr. Atef Ali Ibrahim.
1 Lecture 2  Complement  Floating Point Number  Character Encoding.
CSC 221 Computer Organization and Assembly Language
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Floating Point Arithmetic
Data Representation, Number Systems and Base Conversions
SAK Chapter 21 Chapter 2 : Number System 2.1 Decimal, Binary, Octal and Hexadecimal Numbers 2.2 Relation between binary number system with other.
CEC 220 Digital Circuit Design Binary Codes
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
CS1Q Computer Systems Lecture 2 Simon Gay. Lecture 2CS1Q Computer Systems - Simon Gay2 Binary Numbers We’ll look at some details of the representation.
DIGITAL SYSTEMS Number systems & Arithmetic Rudolf Tracht and A.J. Han Vinck.
CS311-Computer OrganizationCalculations in ComputersLecture Lecture 4 Calculations in Computers.
DATA REPRESENTATION Data Types Complements Fixed Point Representations
N 3-1 Data Types  Binary information is stored in memory or processor registers  Registers contain either data or control information l Data are numbers.
Cosc 2150: Computer Organization Chapter 9, Part 3 Floating point numbers.
Floating Point Arithmetic – Part I
MATH Lesson 2 Binary arithmetic.
Floating Point Numbers
Programming and Data Structure
Number Representation
Introduction To Computer Science
DATA REPRESENTATION Data Types Complements Fixed Point Representations
CS1010 Programming Methodology
Chapter 2 Bits, Data Types & Operations Integer Representation
Data Representation Data Types Complements Fixed Point Representation
DATA REPRESENTATION Data Types Complements Fixed Point Representations
Data Representation – Chapter 3
DATA REPRESENTATION Data Types Complements Fixed Point Representations
DATA REPRESENTATION Data Types Complements Fixed Point Representations
Chapter 1 Introduction.
Presentation transcript:

CS311-Computer OrganizationInformation RepresentationLecture 03-1 Lecture 3 Information Representation

CS311-Computer OrganizationInformation RepresentationLecture 03-2 Lecture 3: Information Representation In this lecture, we will study What to think about when representing information in the computer system What is the meaning of the Internal Representation and the External Representation ? Internal Representation –Representation of Numbers Fixed point representation »Sign plus magnitude »1’s complement »2’s Complement Floating point representation –Representation of Nonnumeric data External Representation –ASCII, EBCDIC, 6-bit BCD Chinese Remainder Representation

CS311-Computer OrganizationInformation RepresentationLecture 03-3 Considerations for Information Representation Storage Space(number of bits for a code) Convenience for information interchange Efficiency for information processing Simplicity for conversion from/to decimal system Precision of representation Human Machines Character, Decimal Number Code(binary)

CS311-Computer OrganizationInformation RepresentationLecture 03-4 Internal and External Representations Other Computer Device Human External Representation External Representation External Representation CPU Memory Internal Representation

CS311-Computer OrganizationInformation RepresentationLecture 03-5 External Representation –ASCII, EBCDIC, 6-bit BCD, … Internal Representation –Nonnumeric data Processing does not modify data - e.g. word processing simply exchange or ordering of letters Use identical internal and external representations –no need for conversion –Numeric Data Scientific Applications –Range of number is wide - Internal representation for precision reason –Fast Calculation - Internal representation for speed reason –CPU bound - conversion of codes for infrequent I/O operations is acceptable Commercial Data Processing –High volume I/O - Code Conversion for I/O is not acceptable –Complex calculation is rare - external representation is acceptable Internal and External Representations

CS311-Computer OrganizationInformation RepresentationLecture 03-6 Representation of Data Structures There exists relationship between data –Predecessor and successor –Superior, peer, subordinate –membership –etc Storage of data in a 1-dimensional memory space –Representation of relationships in 1-dimensional memory space is not unique –Simple linear list, string, array, and other complex structures

CS311-Computer OrganizationInformation RepresentationLecture 03-7 Internal Representation of Numbers Roman Number Decimal Number - a non-positional number system - a positional number system + I II III IIII V … I II III IIII V VI... II III IIII V VI VII... III IIII V VI VII VIII … IIII V VI VII VIII VIIII … V VI VII VIII VIIII X … VI VII VIII VIIII X XI … Addition Table is infinite Inefficient Impossible to build an Adder Addition Table is finite Easy to convert to/from decimal Possible to build an Adder Smaller table implies cheaper to build Adder - Binary......

CS311-Computer OrganizationInformation RepresentationLecture 03-8 Internal Representation of Numbers Binary Code(Base 2) Easy to convert to/from Decimal Cheapest code to build ALU Binary number is a positional number system which uses the smallest number of symbols Positional Number System Representation: A R = a n a n-1 … a 1 a 0. a -1 … a -m where 0 < a i < R, and R is the base or radix n-1 Equivalent decimal value: V(A R ) =  a i. R i i = -m

CS311-Computer OrganizationInformation RepresentationLecture 03-9 Fixed Point Number Representation A number representation in which the location of the fractional point is fixed Overflow The number to be represented is either too large, or too small(underflow) that the number cannot be precisely represented with the given number of bits. Complement of a number A (R-1)’s Complement(1’s Complement, when R=2) - For each position, subtract the number from (R-1), or - Base R representation of R n - R -m - |A| R’s Complement(2’s Complement, when R=2) - Add 1 to the (R-1)’s complement, or - If A=0, then 0, else base R representation of R n - |A|

CS311-Computer OrganizationInformation RepresentationLecture B 2 = b n b n-1 … b 1 b 0. b -1 … b -m b n :sign bit b n-1 … b 1 b 0. b -1 … b -m :magnitude bits b n-1 … b 1 b 0 : Integer part b -1 … b -m : Fractional part Computer systems rarely use both Integer and fractional parts, instead most computers use either Integer(Integer machine) or Fractional(Fractional machine) part only Sign plus magnitude representation (Sign plus) 1’s complement representation (Sign plus) 2’s complement representation Binary Number Representation

CS311-Computer OrganizationInformation RepresentationLecture Sign Plus Magnitude Representation B = b n b n-1 … b 1 b 0. b -1 … b -m b n :sign bit b n-1 … b 1 b 0. b -1 … b -m :magnitude bits n-1 V S (B) = (-1) bn  b i. 2 i i = -m Easy to convert to the negative number Range of representation; Max:011 … … 1(2 n - 2 -m ) Min:111 … … 1-(2 n - 2 -m ) 2 representations of zero; +0:000 … … 0 - 0:100 … … 0

CS311-Computer OrganizationInformation RepresentationLecture ’s Complement Representation B = b n b n-1 … b 1 b 0. b -1 … b -m b n :sign bit b n-1 … b 1 b 0. b -1 … b -m :magnitude bits n-1 V 1 (B) = b n (2 -m - 2 n ) +  b i. 2 i i = -m Range of representation; Max:011 … … 1(2 n - 2 -m ) Min:100 … … 0-(2 n - 2 -m ) 2 representations of zero; +0:000 … … 0 - 0:111 … … 1

CS311-Computer OrganizationInformation RepresentationLecture ’s Complement Representation B = b n b n-1 … b 1 b 0. b -1 … b -m b n :sign bit b n-1 … b 1 b 0. b -1 … b -m :magnitude bits n-1 V 2 (B) = -b n 2 n +  b i. 2 i i = -m Range of representation; Max:011 … … 1(2 n - 2 -m ) Min:100 … … 0-2 n Representations of zero; 000 … … 0

CS311-Computer OrganizationInformation RepresentationLecture ComparisonComparison Easiness of negative conversion –S+M > 1’s Complement > 2’s Complement Hardware –S+M: Need an Adder and a Subtractor for addition –1’s and 2’s complement: Need only an Adder Speed of Arithmetic –2’s Complement > 1’s Complement (end-around carry) Recognition of zero –2’s Complement is fast

CS311-Computer OrganizationInformation RepresentationLecture Time Out 화가가 화랑 주인에게 자기 그림에 대해 관심을 보이는 사람이 없 더냐고 물었다. 화랑 주인이 대답했다. “ 좋은 소식도 있고, 나쁜 소식도 있지요.” “ 좋은 소식은 내가 어떤 손님에게 당신이 죽고 나면 당신 그림 값 이 크게 오를 것이라고 했더니 그 사람이 당신 그림을 몽땅 산거 지요.” “ 나쁜 소식은 그 손님이 당신의 주치의라는 것입니다.”

CS311-Computer OrganizationInformation RepresentationLecture Floating Point Representation 19,850,000,000, ,000,000,034,82 Fixed point representation has the precision problem Various representations of a very large or very small numbers; 1,985 x can be represented as x 10 14, x 10 13, x 10 12, x 10 11, … x can be represented as x , x , x , 3,482 x , … Floating Point Number: F F = AB b n a k a k-1 … a 0 b n-1 … b 1 b 0. b -1 … b -m sign exponent mantissa Equivalent Decimal Value V F (F) = V(B) x 2 V(A)

CS311-Computer OrganizationInformation RepresentationLecture Floating Point Number: Representation of Zero Representation of Zero –Zero Mantissa = 0 –Real Zero Mantissa = 0 Exponent: Smallest number that can be represented with given bits 00 … 0 is most suitable representation Needs to add Bias to the exponent value so that the smallest exponent can be represented with 00…0 Example: Assume 3-bit exponent bias =000Bias =

CS311-Computer OrganizationInformation RepresentationLecture Normal Form –Unified representation makes the comparison of numbers easy –A representation that represents the given number most precisely by utilizing the most significant bit of mantissa –e.g. Mantissa: Fractional representation with 4 decimal digits Floating Point Number: Normalization x 10 2, x 10 3, x 10 4, x 10 5 Normal Form S Exponent Mantissa Significant bit(s) is(are) wasted

CS311-Computer OrganizationInformation RepresentationLecture Internal Number Representation: Decimal Representation Arithmetic with Decimal Numbers –No need to convert between decimal and other representations Commercial data processing applications BCD Decimal digit log 2 10 = 4 4-bit BCD – – Unused code space – – Slow arithmetic

CS311-Computer OrganizationInformation RepresentationLecture BCD(Binary Coded Decimal) –4-bit code with 8, 4, 2, 1 weight on each bit (8421 code) –Difficult to convert to 9’s complement for the negative number representation 2421 code, code, excess 3 code for this purpose Decimal Number Representation: BCD DecimalBCD excess ’s complement representation

CS311-Computer OrganizationInformation RepresentationLecture Totem in Sunrise

CS311-Computer OrganizationInformation RepresentationLecture bit BCD –4-bit BCD + 2 bits –Representation of numeric as well as nonnumeric symbols –Capital and Small English letters are not distinguishable –Suitable for computers with the word length of multiples of 6 ASCII –Representation of 128 letters with 7 bits –8-bit ASCII <= 7-bit ASCII + 1 parity bit EBCDIC –8-bit code Nonnumeric Representation

CS311-Computer OrganizationInformation RepresentationLecture Internal Representation of Numbers: Chinese Remainder Theorem Conversion to decimal n Let Nj =  mi i=1, i= j n A = |  N i | a i / N i | mi | M, where |X| M represents X modulo M i=1 Chinese Remainder Theorem A set of n relatively prime numbers: m 1, m 2, …, m n A set of remainders {a 1, a 2, …, a n } uniquely determines an integer A in the range of 0 < A < M, where n M =  m i i=1

CS311-Computer OrganizationInformation RepresentationLecture A=23; Chinese Remainder Representation A = (1, 2, 3) m 1 = 2, m 2 = 3, m 3 = 5;M = 2 x 3 x 5 = 300 < 23 < 30 a 1 = |23| 2 = 1 a 2 = |23| 3 = 2 a 3 = |23| 5 = 3 Conversion to decimal: N 1 = m 2 x m 3 = 3 x 5 = 15 N 2 = m 1 x m 3 = 2 x 5 = 10 N 3 = m 1 x m 2 = 2 x 3 = 6 A = |(15 x |1/15| 2 ) + 10 x (|2/10| 3 ) + 6 x (|3/6| 5 ) | 30 = |(15 x |1/1| 2 ) + 10 x (|2/1| 3 ) + 6 x (|3/1| 5 ) | 30 = | | 30 = |53| 30 = 23

CS311-Computer OrganizationInformation RepresentationLecture Very compact code - mi-remainders –Allows to calculate with smaller numbers –Faster with smaller numbers Significance of Chinese Remainder Representation mi-complement arithmetic is possible Difficult to compare values of numbers No carries to propagate between mi-remainders (although we have to consider the carry propagation within an mi-remainder) Division is extremely difficult We have a 32-bit computer. Assume that we have to deal with a very large fixed point number which can not be fitted into a 32-bit register. If we select a set of prime numbers that can be represented with 32 bits, the number that we have to deal with can be represented with a code consists of a set of 32-bit numbers.