8 September How Computers Work Storing Data Numbers
8 September How Computers Work: Storing Data -- Numbers
Announcements n Possible make up slots: n n n 9 – 9: 50 on Friday 4 – 5: 15 on Friday And the winner is … n 9 – 9: 50
How We’ll Proceed n Every class: discussion of a current event or famous bug n n n I’ll take the first few, then Students to present and lead discussion After we complete how computers work, we’ll alternate between n n how computers are used and how we program computers
Current events n Star 38: computer service that allows you to generate a bogus phone number for caller id Privacy issue: is this ethical? n http: //www. nytimes. com/2004/09/02/technology/02 caller. html? th n
How Data is Stored n n Binary System Types of Information n n Numbers Text Pictures Boolean values Other?
Binary System n Everyone knows that computers store bits, right? n n n Why? What does it mean? Stored in a fixed size unit n n Every bit must be set: leading zeroes 1 = 001 = …
Storage containers n Computers are based on words: the natural size container for the machine n n Words are typically 32 bits large Data can be stored in word, half word, or double word Numeric data uses one of these formats Computers also work in bytes (8 bits) n Text data uses this format
Representing Numbers n Additive system n n lllll Every item represents 1 Examples of additive systems? Positional system n n Value = face * place 37 = 3*10 + 7*1
Positional System n Base = number of different values in a position n Base 10 = 10 values: 0 -9 Base 5 = 5 values: 0 -4 Value of each position = power of base n b 4 b 3 b 2 b 1 b 0
Practice n n n 4627 = 4 x 72 + 6 x 71 + 2 x 70 4 x 49 + 6 x 7 + 2 196 + 42 + 2 240 4145 = 4 x 52 + 1 x 51 + 4 x 50 = 34 2123 = 2 x 32 + 1 x 31 + 2 x 30 = 23
Binary Positional System n n n 24 23 22 21 20 16 8 4 2 1 Examples n n n 1111 = 15 1000 = 8 01100100 = 100
Adding in binary n Four arithmetic facts n 0+0=0, 0+1=1, 1+0=1; 1+1=10 0101 +0010 +0001 0110
Practice n n 0111 + 1 = 1000 1011 + 101 = 10000
Converting to Binary n n How would you do it? Try 24 What’s the largest power of 2 that is smaller than 24? n n n 24 – 16 = 8 n n 11 xxx 8– 8=0 n n 1, 2, 4, 8, 16, 32, 64, … 1 xxxx 11000 Other algorithms?
Another Way to Convert n 24 / 2 = 12 r 0 n n 12 / 2 = 6 r 0 n n 000 3/2=1 r 1 n n 00 6/2=3 r 0 n n 0 1000 1/2=0 r 1 n 11000
Shorthand: Base 16 n n Binary numbers are hard to read Groups of 4 bits as a single value n n How should we write 10? n n hexadecimal 10=A, 11=B, 12=C, 13=D, 14=E, 15=F BEAD 16 = Bx 163+Ex 162+Ax 161+Dx 160 = 11 x 4096 + 14 x 256 + 10 x 16 + 13 x 1 = 45056 + 3584 + 160 + 13 = 48813
Coming Attractions n Next week we’ll finish up on how computers work n n n Numeric data Other data types Input and Output Time to ask questions about material Monday, September 20 n n Short quiz Start on computers in society
- Slides: 17