Top Banner
ICC Module Computation – Information Representation 1 Information, Computation, and Communication Representation of Information
28

Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

Sep 23, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

1

Information, Computation, and Communication

Representation of Information

Page 2: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

2

Computation works with information

Scientific

computation/simulation

--> numbers

Googledatacenter

Information

management--> text, photos, movies…

Control process

-->signals(measurements, control...)

Page 3: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

3

§ Which ways can we use to represent numbers and symbols?

§ Is it possible to build an exact representation of the real world?

Objectives

Page 4: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

4

§ Representation of the information

§ Natural Numbers (e.g., 2 4 5 6): operations/domain

§ Integers (e.g., -1 -5 4 45698) - Videos

§ Reals (e.g., 3.4 4.756): fix and floating point - Videos

§ From the alphabet to the ideograms (next week)

Agenda

Page 5: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

5

A representation is a convention

1 billion of people understand it…

It is not difficult to assign meaning to a symbol but to agree on a common way to interpret it.

A Convention

Page 6: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

6

AB C …

214 graphical motifs, called keys, were used to build ~100.000 Chinese ideograms

The 26 letters of the Latin alphabet have been used to build/create ~1.000.000 words of western languages

The 10 Arabic digits allow us to create an infinity of numbers (and even encrypt all the words!)

Question: which one is the simplest system of signs allowing to keep/save/preserve the same expression wealth/richness like the 10 digits?

Answer: a system of 2 symbols

Towards the elementary unit of information

0 1 2 3…

Page 7: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

7

All information can be represented with the help of a set of binary elements

In agreement, a binary element is worth 0 or 1.

In agreement we use the English expression “binary digit ” or bit in short (abbreviated)

Shortcut for bit: b or bit

A Bit

Page 8: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

8

21 distinct pieces of information

1 bit0

1

How to represent more information?

distinct pieces of information2 bits

1

0

01

1 1

0

0 0

122

Page 9: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

9

Exercise:How many bits do we need to represent

• the days of the week:

• the digits 0 to 9 :

• the letters of the alphabet:

• upper case

• upper + lower case

• upper + lower case + signs ...

n bits allow us to represent 2n distinct pieces of information2n distinct pieces of information can be represented by

log2(2n) = n log2 (2) = n bits

General rule:For K distinct information, the number ofbits n needed to represent this information

is the integer higher or equal to log2 K

1

2

2

4

3Th

e da

ys o

f the

wee

k

7

8

The

digi

ts fr

om 0

to 9

10

4

16

5

32

The

uppe

rcas

e le

tters

of t

he la

tin a

lpha

bet

26

Page 10: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

10

n bits allow us to represent 2n distinct pieces of information

Good practice for fast estimation:

210 = Kb (Ki) ≈ 103 = kilo (k)220 = Mb (Mi) ≈ 106 = mega (M)230 = Gb (Gi) ≈ 109 = giga (G)

232 = 230+2 = 230 .22 ≈ 4 G

n 2n

1 22 43 84 165 326 647 1288 25610 1'02420 1'048'57630 1'073'741'82432 4'294'967'296

Page 11: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

11

Convention: a byte (octet in French) is a group of 8 bits.

Shortcut for byte: BRecall shortcut for bit: b (or simply bit)

The most common information representations use a byte or a sequence of bytes.

Organization of the information

byte

Page 12: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

12

§ What is the simplest system to represent information?

§ How many bits to you need to store all the days of a year?

§ How many pieces of information can you store with 2B (bytes)?

Quiz

Page 13: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

13

§ Representation of the information

§ Natural Numbers (e.g., 2 4 5 6): operations/domain

§ Integers (e.g., -1 -5 4 45698) - Videos

§ Reals (e.g., 3.4 4.756): fix and floating point - Videos

§ From the alphabet to the ideograms (next week)

Agenda

Page 14: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

14

Representing Natural Numbers (Entier naturel)

Page 15: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

15

Reminder: all numbers can be represented with a set of binary elements.

Definition: a sequence of 0’s and 1’s is called a binary patternA binary pattern on its own is not enough to understand what is encoded.

We need an interpretation method of the binary pattern given as dataOne solution: the positional notation of numbers

How to represent a natural number?

Page 16: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

16

Example of an integer in base 10: 703

The number 703 is the abbreviated notation of the expression:

7 . 102 + 0 . 101 + 3 . 100

§ the digit on the right is always multiplied to the base (10) raised to the power 0

§ the power of the base increases by one from digit to digit, going from right to left

§ this convention of positional notation can be used with any base

Positional notation of numbers

Page 17: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

17

§ Depends on the same conventions as in base 10 (decimal)

§ Most significant (bit) on the left (MSB)§ Least significant (bit) on the right (LSB)

Positional representation in base 2

2021222324252627

MSB LSB

Page 18: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

18

§ From binary to decimal:

§ add the powers of two present in the binary pattern

Practice: Conversions

12481632641282021222324252627

1 1010000

2 1080000 +++++++ = 11

Page 19: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

19

From decimal to binary:decompose an integer X to a sum of powers of two:§ 11dec = 23 + 21 + 20 = 1011bin

Algorithm: take the integer division of the number by 2 as long as the result it larger than or equal to 2

11 = 2.5 + 1 = 2.(2.2 + 1) + 1= 2.(2.(2.1 + 0) +1) + 1= 1.23 + 0.22 + 1.21 + 1.20= 1011

Practice: Conversions

11 div 2 = 5 + 1 rest5 div 2 = 2 + 1 rest2 div 2 = 1 + 0 rest

1011

Page 20: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

20

A representation for a computer is associated to a fix capacity expressed in number of bits (or of bytes).

Example: 32-bit computer. This device has instructions to implement the base operations (addition, multiplication, etc.) very rapidly for numbers represented with 4 bytes (32 bits).

So the limit to the number of different numbers that can be represented is 232

Natural numbers: covered domain (1)

Page 21: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

21

If the representation is of natural numbers (= non-negative integers), its covered domain for 32 bits is:

Min = binary pattern with 0 everywhere = zero

Max = binary pattern with 1

everywhere = 232 --1

232 2021230231

32 bits

Natural Numbers: covered domain (2)

Page 22: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

22

§ If we represent natural numbers with 8 bits using the positional representation in base 2, which numbers can we represent?

§ Which number does the binary patter 1001001 represent, if we interpret it using positional representation in base 2?

§ What is the representation of number 156 using 8 bits in positional representation in base 2?

Quiz

Page 23: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

23

Computations on natural numbers are correct if the desired result is a natural number and belongs to the covered domain

The chosen representation must take into account all possible outcomes

Reasons for capacity overflow:

• integer division: Loss of fractional part

• multiplication, addition, subtraction: propagation of the carry beyond 231

Natural Numbers: covered domain (3)

Page 24: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

24

§ Addition tables with numbers 0-9 and 0-1Addition in Decimal vs Binary

a b a+b0 0 00 1 10 2 2.. .. ..0 9 91 0 11 1 2.. .. ..2 0 22 1 3.. .. ..9 9 1 8

a b a+b0 0 00 1 11 0 11 1 1 0

21 20

Page 25: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

25

Example 1: addition of 2 integer of capacity of one bit

0 0 1 1+0 +1 +0 +1-- -- -- --0 1 1 10

Examples of capacity overflow (1)

the carry is lost

Only one bit for position 20, therefore position 21 is lost.

Page 26: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

26

Example 2: addition with 32 bitsExamples of capacity overflow (2)

231232 20

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

(232 – 1 ) + 1 = ?0

Page 27: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

27

010

Example: on 3 bits

001

011100

101

110

111000

0

1

2

34

5

6

7

Unsigned integers: covered domain and overflow

Page 28: Information, Computation, and Communication ... - EPFL · ICC Introduction 4 Schedule Thursday Friday 10h-11hProgramming (CO1) 9h-11h Theory(SG1) 15h-16h Theory (5 rooms) 17h-19hProgramming(4

ICC Module Computation – Information Representation

28

§ Representation of the information

§ Natural Numbers (e.g., 2 4 5 6): operations/domain

§ Integers (e.g., -1 -5 4 45698) - Videos

§ Reals (e.g., 3.4 4.756): fix and floating point - Videos

§ From the alphabet to the ideograms (next week)

Agenda