Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor...
-
Upload
adam-oneal -
Category
Documents
-
view
214 -
download
0
Transcript of Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor...
![Page 1: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/1.jpg)
Data storage
Charles McAnany
![Page 2: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/2.jpg)
What are the ones and zeroes?
Hard driveComputer
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.
1011010
![Page 3: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/3.jpg)
Definitions
A bit is a single one or zero. A byte is eight bits. Numbers stored as ones and zeroes are stored in binary.
![Page 4: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/4.jpg)
Binary numbers
• A list of ones and zeroes is a number. • It’s just like a number in base ten.
1576 10110Ones p
lace
Thousands place
Hundreds place
Tens place
Ones p
lace
Eight
s plac
eFo
urs p
lace
Twos
plac
e
Sixte
ens p
lace
![Page 5: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/5.jpg)
Converting from binary to decimal
10110One
s plac
e
Eight
s plac
eFo
urs p
lace
Twos
plac
e
Sixte
ens p
lace
Place Power Value Present?1 2^0 1 No2 2^1 2 Yes3 2^2 4 Yes4 2^3 8 No5 2^4 16 Yes
Then, add up all the present values. 16 + 4 + 2 = 22
![Page 6: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/6.jpg)
From decimal to binary• Harder!• Find the largest power of two that fits in the decimal number. • Subtract that number, and mark it as present in the binary. • Repeat until the decimal number is zero.
1577
![Page 7: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/7.jpg)
1577
Place Power Value Present?1 2^0 12 2^1 23 2^2 44 2^3 85 2^4 166 2^5 327 2^6 648 2^7 1289 2^8 256
10 2^9 51211 2^10 1,02412 2^11 2,04813 2^12 4,09614 2^13 8,19215 2^14 16,384
Largest power of two that fits:1024 (not 2048, because 2048 > 1577.)
1577-1024= 553
Mark the 1024 spot, and continue with 553.
![Page 8: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/8.jpg)
553
Place Power Value Present?1 2^0 12 2^1 23 2^2 44 2^3 85 2^4 166 2^5 327 2^6 648 2^7 1289 2^8 256
10 2^9 51211 2^10 1,024 yes12 2^11 2,04813 2^12 4,09614 2^13 8,19215 2^14 16,384
Largest power of two that fits:512
553- 512= 41
Mark the 512 spot, and continue with 41.
![Page 9: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/9.jpg)
41
Place Power Value Present?1 2^0 12 2^1 23 2^2 44 2^3 85 2^4 166 2^5 327 2^6 648 2^7 1289 2^8 256
10 2^9 512 yes11 2^10 1,024 yes12 2^11 2,04813 2^12 4,09614 2^13 8,19215 2^14 16,384
Largest power of two that fits:32
41- 32= 9
Mark the 32 spot, and continue with 9.
![Page 10: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/10.jpg)
9
Place Power Value Present?1 2^0 12 2^1 23 2^2 44 2^3 85 2^4 166 2^5 32 yes7 2^6 648 2^7 1289 2^8 256
10 2^9 512 yes11 2^10 1,024 yes12 2^11 2,04813 2^12 4,09614 2^13 8,19215 2^14 16,384
Largest power of two that fits:8
9- 8= 1
Mark the 8 spot, and continue with 1.
![Page 11: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/11.jpg)
1
Place Power Value Present?1 2^0 12 2^1 23 2^2 44 2^3 85 2^4 166 2^5 32 yes7 2^6 648 2^7 1289 2^8 256
10 2^9 512 yes11 2^10 1,024 yes12 2^11 2,04813 2^12 4,09614 2^13 8,19215 2^14 16,384
Largest power of two that fits:1
1- 1= 0
Mark the 1 spot, the number is zero, so you’re done.
![Page 12: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/12.jpg)
Place Power Value Present?1 2^0 1 yes2 2^1 23 2^2 44 2^3 85 2^4 166 2^5 32 yes7 2^6 648 2^7 1289 2^8 256
10 2^9 512 yes11 2^10 1,024 yes12 2^11 2,04813 2^12 4,09614 2^13 8,19215 2^14 16,384
Wherever you marked present, that’s a 1. If there’s no mark, that number’s a 0. Starting at the bottom, fill in the binary number.The number is 000011000100001.
![Page 13: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/13.jpg)
Playing for money.
• The first person to convert the following number to binary will receive a cash prize.
• The number is: 200,000,000.
![Page 14: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/14.jpg)
Text
• Each byte is a character. So, each character has a number. The capital letters are in the handout.
• The following string (bytes separated by commas) is:
• 01001000, 01000101, 01001100, 01001100, 01001111
• H E L L O• Please take a moment to write your name in
binary.
![Page 15: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/15.jpg)
Images:Images are broken into pixels.
Each color is given a number.Blue = 0, Light blue = 1, red = 2, white = 3
00 01 00 01 10 10 10
00 00 00 00 11 11 11
00 01 00 01 10 10 10
11 11 11 11 11 11 11
10 10 10 10 10 10 10
Then, store the numbers, and any other info needed to make the image.The image format might specify, for instance, the first eight bits is the row length. So, our file would be
Glue the rows together. (remembering howlong a row is elsewhere.)
00 01 00 01 10 10 10 00 00 00 00 11 11 11 00 01 00 01 10 10 10 11 11 11 11 11 11 11 10 10 10 10 10 10 10
000001110001000110101000000000111111000100011010101111111111111110101010101010
![Page 16: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/16.jpg)
Recreating an image.
• The first eight bits are the row length. Use the coloring scheme in the handout.
• Here’s the file as it appears on the disk. Recreate the image. (I’ve broken it into bytes for ease of reading.)
• 00000101• 00010001• 00000010• 00001100• 00001100• 11111100
![Page 17: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/17.jpg)
Compression
• If a particular pattern occurs often in a file, it may be possible to compress the contents. We’ll use Huffman coding to deflate a text file.
• The original text is “this is an example of a huffman tree”.
• We start by analyzing letter frequency. The most common letters should have the shortest codes.
![Page 18: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/18.jpg)
Huffman codingChar Freq Code
space 7 111
a 4 010
e 4 000
f 3 1101
h 2 1010
i 2 1000
m 2 0111
n 2 0010
s 2 1011
t 2 0110
l 1 11001
o 1 00110
p 1 10011
r 1 11000
u 1 00111
x 1 10010
To encode, we replace each character with itsHuffman code. The word “tree” is originally 01010100 01010010 01000101 01000101Replacing it with the codes, we get:011011000000000
![Page 19: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/19.jpg)
Image compression using Huffman coding
• Our image example used two bits for every pixel. That’s great for images with four colors. But most images are stored using 32 or even 64 bits per pixel.
• If most of the image is one color, we can give that color a code of very few bits, converting all of those 64-bit pixels into 1 bit pixels.
![Page 20: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/20.jpg)
Other compression methods
• Huffman coding is very widely used in lossless compression. When you view the data that was encoded, you get the EXACT same data back.
• But some things (music and images in particular) may not need to be stored with perfect accuracy.
• For these, we use lossy compression.
![Page 21: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/21.jpg)
Lossy compression
![Page 22: Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.](https://reader031.fdocument.pub/reader031/viewer/2022032311/56649da95503460f94a975b7/html5/thumbnails/22.jpg)
Credits
• Maru the cat http://catsnco.wordpress.com/2011/10/19/i-am-maru/
• Huffman tree http://en.wikipedia.org/wiki/Huffman_coding
• Lossy compression NMR http://nmr.cemhti.cnrs-orleans.fr/Dmfit/Howto/Top/Default.aspx