- 73 Views
- Uploaded on
- Presentation posted in: General

Lecture 3 Information Representation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Lecture 3Information Representation

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

- Fixed point representation
- Representation of Nonnumeric data

- Representation of Numbers
- External Representation
- ASCII, EBCDIC, 6-bit BCD

- Chinese Remainder Representation

Information Representation

Human Machines

Character, Decimal NumberCode(binary)

- 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

Information Representation

Other

Computer

Internal

Representation

Human

CPU

Memory

Device

External

Representation

External

Representation

External

Representation

Information Representation

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

- Scientific Applications

Information Representation

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

Information Representation

+ 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

. . . . . .

. . . . . .

. . . . . .

Roman Number Decimal Number

- a non-positional number system - a positional number system

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

Information Representation

Positional Number System

Representation: AR = an an-1 … a1 a0 . a-1 … a-m

where 0 < ai < R, and R is the base or radix

n-1

Equivalent decimal value: V(AR) = S ai . Ri

i = -m

Binary number is a positional number system which

uses the smallest number of symbols

- Binary Code(Base 2)
- Easy to convert to/from Decimal
- Cheapest code to build ALU

Information 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 Rn - 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 Rn - |A|

Information Representation

B2 = bn bn-1 … b1 b0 . b-1 … b-m

bn:sign bit

bn-1 … b1 b0 . b-1 … b-m :magnitude bits

bn-1 … b1 b0 : 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

Information Representation

B = bn bn-1 … b1 b0 . b-1 … b-m

bn:sign bit

bn-1 … b1 b0 . b-1 … b-m :magnitude bits

n-1

VS(B) = (-1)bnS bi . 2i

i = -m

Easy to convert to the negative number

Range of representation;

Max:011 … 11 . 11 … 1(2n - 2-m)

Min:111 … 11 . 11 … 1-(2n - 2-m)

2 representations of zero;

+0:000 … 00 . 00 … 0

- 0:100 … 00 . 00 … 0

Information Representation

B = bn bn-1 … b1 b0 . b-1 … b-m

bn:sign bit

bn-1 … b1 b0 . b-1 … b-m :magnitude bits

n-1

V1(B) = bn(2-m - 2n) + S bi . 2i

i = -m

- Range of representation;
Max:011 … 11 . 11 … 1(2n - 2-m)

Min:100 … 00 . 00 … 0-(2n - 2-m)

- 2 representations of zero;
+0:000 … 00 . 00 … 0

- 0:111 … 11 . 11 … 1

Information Representation

B = bn bn-1 … b1 b0 . b-1 … b-m

bn:sign bit

bn-1 … b1 b0 . b-1 … b-m :magnitude bits

n-1

V2(B) = -bn 2n + S bi . 2i

i = -m

- Range of representation;
Max:011 … 11 . 11 … 1(2n - 2-m)

Min:100 … 00 . 00 … 0-2n

- Representations of zero;
000 … 00 . 00 … 0

Information Representation

- 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

Information Representation

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

Information Representation

bn ak ak-1 … a0bn-1 … b1 b0 . b-1 … b-m

sign exponent mantissa

Fixed point representation has the precision problem

19,850,000,000,000

.000,000,000,034,82

Various representations of a very large or very small numbers;

1,985 x 1010 can be represented as

0.1985 x 1014, 1.985 x 1013, 19.85 x 1012, 198.5 x 1011, …

0.3482 x 10-10can 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

Equivalent Decimal Value VF(F) = V(B) x 2V(A)

Information Representation

- 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

- Zero

Example: Assume 3-bit exponent

+3011

+2010

+1001

+0000

-0111

-1110

-2101

-3100

111

110

101

100

011

010

001

+100

100+ bias =000

Bias = 100

Information Representation

S Exponent Mantissa

Significant bit(s)

is(are) wasted

Normal Form

37.26 0.3726 x 102 , 0.0372 x 103, 0.0037 x 104, 0.0003 x 105

- 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

+ 2 .3726

+ 3 .0372

+ 4 .0037

+ 5 .0003

. . .

Information Representation

BCD Decimal

00000

00011

00102

00113

01004

01015

01106

01117

10008

10019

1010-

1011-

1100-

1101-

1110-

1111-

- 1 digit log2 10 = 4 4-bit BCD
- Unused code space

- Slow arithmetic

- Arithmetic with Decimal Numbers
- No need to convert between decimal and other representations

- Commercial data processing applications

Information Representation

DecimalBCD242184-2-1excess 3

00000000000000011

10001000101110100

20010001001100101

30011001101010110

40100010001000111 9’s complement

50101101110111000 representation

60110110010101001

70111110110011010

81000111010001011

91001111111111100

Decimal Number Representation:BCD

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

Information Representation

Totem in Sunrise

Information Representation

- 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

Information Representation

Chinese Remainder Theorem

A set of n relatively prime numbers: m1, m2, … , mn

A set of remainders {a1, a2, … , an} uniquely determines an integer A in the range of 0 < A < M, where

n

M = P mi

i=1

Conversion to decimal

n

Let Nj = P mi

i=1, i= j

n

A = | S Ni | ai / Ni |mi |M , where |X|M represents X modulo M

i=1

Information Representation

0 < 23 < 30

A = (1, 2, 3)

m1 = 2, m2 = 3, m3 = 5;

M = 2 x 3 x 5 = 30

A=23;

a1 = |23|2 = 1

a2 = |23|3 = 2

a3 = |23|5 = 3

Conversion to decimal:

N1 = m2 x m3 = 3 x 5 = 15

N2 = m1 x m3 = 2 x 5 = 10

N3 = m1 x m2 = 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

Information Representation

- Very compact code - mi-remainders
- Allows to calculate with smaller numbers
- Faster with smaller numbers

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.

- 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

Information Representation