Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store.

Similar presentations


Presentation on theme: "Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store."— Presentation transcript:

1 Lecture # 5 Data Representation

2 Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store data? 2.Explain: Data Types: Binary numbers, Integers, Floating Point, Booleans, Characters, Variables 3.Demo: Do some binary conversions: on board 4.Practice: Do some binary examples: in head, on keyboard 5.Evaluate: We will share and evaluate your conversions 6.Re-practice: Turn the crank on binary as you go to sleep Understand Data Types, Storage ReviewPrograms

3 Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store data? 2.Explain: Data Types: Binary numbers, Integers, Floating Point, Booleans, Characters, Variables 3.Demo: Do some binary conversions: on board 4.Practice: Do some binary examples: in head, on keyboard 5.Evaluate: We will share and evaluate your conversions 6.Re-practice: Turn the crank on binary as you go to sleep Understand Data Types, Storage ReviewPrograms

4 Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store data? 2.Explain: Data Types: Binary numbers, Integers, Floating Point, Booleans, Characters, Variables 3.Demo: Do some binary conversions: on board 4.Practice: Do some binary examples: in head, on keyboard 5.Evaluate: We will share and evaluate your conversions 6.Re-practice: Turn the crank on binary as you go to sleep Understand Data Types, Storage ReviewPrograms

5 Data Representation If we want to compare, sort and organize data, we need to have a way to represent it in a computer – electronically. Even the characters you are now reading, as words, must be able to be represented and encoded electronically and numerically. The following slides will explain how we represent and encode data in a computer, and how we manipulate and reason about it in a computer program.

6 How to Represent Data in a Computer

7 Foundations of Computing Information Data Types –Binary numbers –Integers and Floating Point –Booleans (True, False) –Characters –Variables Programs –Expressions –Assignment –Sequences

8 There are 10 kinds of people in the world – those who understand binary and those who do not.

9 Information Data Types  Binary numbers Integers and Floating Point Booleans (True, False) Characters Variables

10 Decimal Numbers Each digit is a power of ten 12345 = 5 * 10 0 +5*1 + 4 * 10 1 +4*10 + 3 * 10 2 +3*100 + 2 * 10 3 +2*1000 + 1 * 10 4 1*10,000

11 Binary Numbers Each Digit is a power of two 10110 = 0 * 2 0 (1)+ 1 * 2 1 (2)+ 1 * 2 2 (4)+ 0 * 2 3 (8)+ 1 * 2 4 (16) = 22

12 Binary Numbers Each Digit is a power of two 1011101 = = 93 1 * 2 0 (1) + 0 * 2 1 (2) + 1 * 2 2 (4) + 1 * 2 3 (8) + 1 * 2 4 (16) + 0 * 2 5 (32) + 1 * 2 6 (64)

13 Why Binary? Any physical phenomenon that has two states can be used to store a binary number 11010= 26

14 Magnetism + - + - + + Magnetic Material Read/Write Head 1 101011 = 43

15 Voltage +5 000 100101= 37

16 Holes in Paper Light = 1 Dark = 0 101010 = 42 Photo Sensor Light

17 Binary Students Male = 0 Female = 1

18 Why Binary? Any physical phenomenon that has two states can be used to store a binary number Each binary digit is called a BIT –1010 - is a 4 bit number –01010100 - is an 8 bit number An 8 bit number is called a BYTE

19 Size of a Binary Number How many different numbers can you store in 2 bits? How many can you store in 8 bits? In general, 2 (number of bits) numbers can be stored How many in 10 bits? –1024 = 1K How many in 20 bits? –1,048,576 = 1Meg

20 Information Binary numbers  Integers and Floating Point Booleans (True, False) Characters Variables

21 Integers 100 100245 -45

22 Size of an Integer How many bits required for the number 17? 5 bits How many bits for the number 1023? 10 bits

23 Integer Expressions * means multiply / means divide 2*4+3 = 11 2*(4+3) = 14 (7+9)/2 = 8

24 Floating point numbers Numbers with decimal points 1.23 5623.1232 -0.00232

25 Floating point numbers Numbers with decimal points 1.23 = 0.123e1 5623.1232 = 0.56231232e4 -0.00232=-0.232e-2 Stored differently (sign + fraction + exponent)

26 Information Binary numbers Integers and Floating Point  Booleans (True, False) Characters Variables

27 Booleans 1 = true 0 = false

28 Boolean Expressions (7>3) is true ((2+4)<6) is false –Note Arithmetic Expression in Boolean Expression > Greater than < less than <= less than or equal >= greater than or equal == equal != not equal 7<=6 is false 6!=5 is true

29 Information Binary numbers Integers and Floating Point Booleans (True, False)  Characters Variables

30 ASCII Code for Characters Every character is defined to have an 8 bit (1 byte) number What is special about the order of the numbers? Type ‘ g ’ Store 103

31 ASCII Code for Characters A numeric character is different from its ASCII number

32 ASCII Code for Characters Dad32@Abc 68 97 100 51 50 64 65 98 99

33 What about Chinese, Sanscrit, Hebrew, Cyrillic, etc ??

34 UNICODE rather than ASCII 2 Bytes per character –Twice as much space –65,536 possible characters (2^16)

35 Expressions with characters ‘ A ’ + 2 = ‘ C ’ ‘ g ’ - ‘ d ’ = 3 ‘ F ’ + 32 = ‘ f ’ ‘ A ’ < ‘ D ’ is true ‘ % ’ >= ‘ + ’ is false

36 Information Binary numbers Integers and Floating Point Booleans (True, False) Characters  Variables

37 Variable A named place to store a value –George = 32 –Size = 17 –Weight = 120

38 Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store data? 2.Explain: Data Types: Binary numbers, Integers, Floating Point, Booleans, Characters, Variables 3.Demo: Do some binary conversions: on board 4.Practice: Do some binary examples: in head, on keyboard 5.Evaluate: We will share and evaluate your conversions 6.Re-practice: Turn the crank on binary as you go to sleep Understand Data Types, Storage ReviewPrograms

39 Binary Exercise Binary devices include: The binary number 101101 = what in decimal? How many bits are required to store the decimal number 256?

40 Review Binary devices include: paper and magnetic tape, disks, transistors The binary number 101101 = what in decimal? 45 How many bits are required to store the decimal number 256? 9 bits

41 Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store data? 2.Explain: Data Types: Binary numbers, Integers, Floating Point, Booleans, Characters, Variables 3.Demo: Do some binary conversions: on board 4.Practice: Do some binary examples: in head, on keyboard 5.Evaluate: We will share and evaluate your conversions 6.Re-practice: Turn the crank on binary as you go to sleep Understand Data Types, Storage ReviewPrograms

42 Programs Computer Programs make use of a these data types to perform a given task Standard arithmetic operations can be applied to manipulate the input data types and output a result


Download ppt "Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store."

Similar presentations


Ads by Google