Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "CS311-Computer OrganizationInformation RepresentationLecture 03-1 Lecture 3 Information Representation."— Presentation transcript:

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

2 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

3 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)

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

5 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

6 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

7 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 … + 0 1 2 3 4 5 6 7 8 9 0 0 1 2 3 4 5 6 7 8 9 1 1 2 3 4 5 6 7 8 9 10 2 2 3 4 5 6 7 8 9 10 11 3 3 4 5 6 7 8 9 10 11 12 4 4 5 6 7 8 9 10 11 12 13 5 5 6 7 8 9 10 11 12 13 14 6 6 7 8 9 10 11 12 13 14 15 7 7 8 9 10 11 12 13 14 15 16 8 8 9 10 11 12 13 14 15 16 17 9 9 10 11 12 13 14 15 16 17 18 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......

8 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

9 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|

10 CS311-Computer OrganizationInformation RepresentationLecture 03-10 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

11 CS311-Computer OrganizationInformation RepresentationLecture 03-11 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 … 11. 11 … 1(2 n - 2 -m ) Min:111 … 11. 11 … 1-(2 n - 2 -m ) 2 representations of zero; +0:000 … 00. 00 … 0 - 0:100 … 00. 00 … 0

12 CS311-Computer OrganizationInformation RepresentationLecture 03-12 1’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 … 11. 11 … 1(2 n - 2 -m ) Min:100 … 00. 00 … 0-(2 n - 2 -m ) 2 representations of zero; +0:000 … 00. 00 … 0 - 0:111 … 11. 11 … 1

13 CS311-Computer OrganizationInformation RepresentationLecture 03-13 2’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 … 11. 11 … 1(2 n - 2 -m ) Min:100 … 00. 00 … 0-2 n Representations of zero; 000 … 00. 00 … 0

14 CS311-Computer OrganizationInformation RepresentationLecture 03-14 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

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

16 CS311-Computer OrganizationInformation RepresentationLecture 03-16 Floating Point Representation 19,850,000,000,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 10 10 can be represented as 0.1985 x 10 14, 1.985 x 10 13, 19.85 x 10 12, 198.5 x 10 11, … 0.3482 x 10 -10 can be represented as 3.482 x 10 -11, 34.82 x 10 -12, 348.2 x 10 -13, 3,482 x 10 -14, … 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)

17 CS311-Computer OrganizationInformation RepresentationLecture 03-17 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 +3011 +2010 +1001 +0000 -0111 -1110 -2101 -3100 100+ bias =000Bias = 100 +100 111 110 101 100 011 010 001

18 CS311-Computer OrganizationInformation RepresentationLecture 03-18 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 37.26 0.3726 x 10 2, 0.0372 x 10 3, 0.0037 x 10 4, 0.0003 x 10 5 Normal Form S Exponent Mantissa + 2.3726 + 3.0372 + 4.0037 + 5.0003... Significant bit(s) is(are) wasted

19 CS311-Computer OrganizationInformation RepresentationLecture 03-19 Internal Number Representation: Decimal Representation Arithmetic with Decimal Numbers –No need to convert between decimal and other representations Commercial data processing applications BCD Decimal 00000 00011 00102 00113 01004 01015 01106 01117 10008 10019 1010- 1011- 1100- 1101- 1110- 1111- 1 digit log 2 10 = 4 4-bit BCD – – Unused code space – – Slow arithmetic

20 CS311-Computer OrganizationInformation RepresentationLecture 03-20 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, 84-2-1 code, excess 3 code for this purpose Decimal Number Representation: BCD DecimalBCD242184-2-1excess 3 00000000000000011 10001000101110100 20010001001100101 30011001101010110 40100010001000111 9’s complement 50101101110111000 representation 60110110010101001 70111110110011010 81000111010001011 91001111111111100

21 CS311-Computer OrganizationInformation RepresentationLecture 03-21 Totem in Sunrise

22 CS311-Computer OrganizationInformation RepresentationLecture 03-22 6-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

23 CS311-Computer OrganizationInformation RepresentationLecture 03-23 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

24 CS311-Computer OrganizationInformation RepresentationLecture 03-24 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 = |15 + 20 + 18| 30 = |53| 30 = 23

25 CS311-Computer OrganizationInformation RepresentationLecture 03-25 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.


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

Similar presentations


Ads by Google