![Page 1: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/1.jpg)
Lecture # 5Data Representation
![Page 2: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/2.jpg)
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
Review Programs
![Page 3: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/3.jpg)
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
Review Programs
![Page 4: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/4.jpg)
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
Review Programs
![Page 5: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/5.jpg)
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.
![Page 6: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/6.jpg)
How to RepresentData in a Computer
![Page 7: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/7.jpg)
Foundations of Computing
• Information Data Types– Binary numbers– Integers and Floating Point– Booleans (True, False)– Characters– Variables
• Programs– Expressions– Assignment– Sequences
![Page 8: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/8.jpg)
There are 10 kinds of people in the world – those who understand binary and those who do not.
![Page 9: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/9.jpg)
Information Data Types
Binary numbers
• Integers and Floating Point
• Booleans (True, False)
• Characters
• Variables
![Page 10: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/10.jpg)
Decimal Numbers
• Each digit is a power of ten12345 =
5 * 100 + 5*1 +
4 * 101 + 4*10 +
3 * 102 + 3*100 +
2 * 103 + 2*1000 +
1 * 104 1*10,000
![Page 11: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/11.jpg)
Binary Numbers
• Each Digit is a power of two10110 =
0 * 20 (1)+
1 * 21 (2)+
1 * 22 (4)+
0 * 23 (8)+
1 * 24 (16)
= 22
![Page 12: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/12.jpg)
Binary Numbers
• Each Digit is a power of two1011101 =
= 93
1 * 20 (1) +
0 * 21 (2) +
1 * 22 (4) +
1 * 23 (8) +
1 * 24 (16) +
0 * 25 (32) +
1 * 26 (64)
![Page 13: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/13.jpg)
Why Binary?
• Any physical phenomenon that has two states can be used to store a binary number
11010 = 26
![Page 14: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/14.jpg)
Magnetism
+ - + - + +
MagneticMaterial
Read/Write Head1
101011 = 43
![Page 15: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/15.jpg)
Voltage
+5 +5 +50 0 0
100101 = 37
![Page 16: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/16.jpg)
Holes in PaperLight = 1Dark = 0
101010 = 42
PhotoSensor
Light
![Page 17: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/17.jpg)
Binary Students
• Male = 0
• Female = 1
![Page 18: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/18.jpg)
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
![Page 19: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/19.jpg)
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
![Page 20: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/20.jpg)
Information
• Binary numbersIntegers and Floating Point
• Booleans (True, False)
• Characters
• Variables
![Page 21: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/21.jpg)
Integers
• 100
• 100245
• -45
![Page 22: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/22.jpg)
Size of an Integer
• How many bits required for the number 17?
• 5 bits
• How many bits for the number 1023?
• 10 bits
![Page 23: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/23.jpg)
Integer Expressions
• * means multiply
• / means divide
• 2*4+3 = 11
• 2*(4+3) = 14
• (7+9)/2 = 8
![Page 24: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/24.jpg)
Floating point numbers
• Numbers with decimal points
• 1.23
• 5623.1232
• -0.00232
![Page 25: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/25.jpg)
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)
![Page 26: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/26.jpg)
Information
• Binary numbers
• Integers and Floating PointBooleans (True, False)
• Characters
• Variables
![Page 27: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/27.jpg)
Booleans
• 1 = true
• 0 = false
![Page 28: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/28.jpg)
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 false6!=5 is true
![Page 29: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/29.jpg)
Information
• Binary numbers
• Integers and Floating Point
• Booleans (True, False)Characters
• Variables
![Page 30: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/30.jpg)
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
![Page 31: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/31.jpg)
ASCII Code for Characters
A numeric character is different from its ASCII number
![Page 32: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/32.jpg)
ASCII Code for Characters
Dad32@Abc68 97 100 51 50 64 65 98 99
![Page 33: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/33.jpg)
What about Chinese, Sanscrit, Hebrew, Cyrillic, etc ??
![Page 34: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/34.jpg)
What about Chinese, Sanscrit, Hebrew, Cyrillic, etc ??
• UNICODE rather than ASCII
• 2 Bytes per character– Twice as much space– 65,536 possible characters (2^16)
![Page 35: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/35.jpg)
Expressions with characters
‘A’ + 2 = ‘C’‘g’- ‘d’ = 3‘F’ + 32 = ‘f’
‘A’ < ‘D’ is true‘%’ >= ‘+’ is false
![Page 36: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/36.jpg)
Information
• Binary numbers
• Integers and Floating Point
• Booleans (True, False)
• CharactersVariables
![Page 37: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/37.jpg)
Variable
• A named place to store a value– George = 32– Size = 17– Weight = 120
![Page 38: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/38.jpg)
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
Review Programs
![Page 39: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/39.jpg)
Binary Exercise
• Binary devices include:
• The binary number 101101 = what in decimal?
• How many bits are required to store the decimal number 256?
![Page 40: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/40.jpg)
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
![Page 41: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/41.jpg)
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
Review Programs
![Page 42: Lecture # 5 Data Representation. Today Questions: From notes/reading/life? Prepare for Quiz # 1 (Multiple Choice) 1.Introduce: How do Computers store](https://reader035.vdocuments.net/reader035/viewer/2022070409/56649e7e5503460f94b81f98/html5/thumbnails/42.jpg)
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