Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.

Similar presentations


Presentation on theme: "Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod."— Presentation transcript:

1 Data storage Charles McAnany

2 What are the ones and zeroes? Hard drive Computer "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

3 Definitions A bit is a single one or zero. A byte is eight bits. Numbers stored as ones and zeroes are stored in binary.

4 Binary numbers A list of ones and zeroes is a number. It’s just like a number in base ten. 1576 10110 Ones place Thousands place Hundreds place Tens place Ones place Eights place Fours place Twos place Sixteens place

5 Converting from binary to decimal 10110 Ones place Eights place Fours place Twos place Sixteens place PlacePowerValuePresent? 12^01No 22^12Yes 32^24Yes 42^38No 52^416Yes Then, add up all the present values. 16 + 4 + 2 = 22

6 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

7 PlacePowerValuePresent? 12^01 22^12 32^24 42^38 52^416 62^532 72^664 82^7128 92^8256 102^9512 112^101,024 122^112,048 132^124,096 142^138,192 152^1416,384 Largest power of two that fits: 1024 (not 2048, because 2048 > 1577.) 1577 -1024 = 553 Mark the 1024 spot, and continue with 553.

8 553 PlacePowerValuePresent? 12^01 22^12 32^24 42^38 52^416 62^532 72^664 82^7128 92^8256 102^9512 112^101,024yes 122^112,048 132^124,096 142^138,192 152^1416,384 Largest power of two that fits: 512 553 - 512 = 41 Mark the 512 spot, and continue with 41.

9 41 PlacePowerValuePresent? 12^01 22^12 32^24 42^38 52^416 62^532 72^664 82^7128 92^8256 102^9512yes 112^101,024yes 122^112,048 132^124,096 142^138,192 152^1416,384 Largest power of two that fits: 32 41 - 32 = 9 Mark the 32 spot, and continue with 9.

10 9 PlacePowerValuePresent? 12^01 22^12 32^24 42^38 52^416 62^532yes 72^664 82^7128 92^8256 102^9512yes 112^101,024yes 122^112,048 132^124,096 142^138,192 152^1416,384 Largest power of two that fits: 8 9 - 8 = 1 Mark the 8 spot, and continue with 1.

11 1 PlacePowerValuePresent? 12^01 22^12 32^24 42^38 52^416 62^532yes 72^664 82^7128 92^8256 102^9512yes 112^101,024yes 122^112,048 132^124,096 142^138,192 152^1416,384 Largest power of two that fits: 1 - 1 = 0 Mark the 1 spot, the number is zero, so you’re done.

12 PlacePowerValuePresent? 12^01yes 22^12 32^24 42^38 52^416 62^532yes 72^664 82^7128 92^8256 102^9512yes 112^101,024yes 122^112,048 132^124,096 142^138,192 152^1416,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.

13 Playing for money. The first person to convert the following number to binary will receive a cash prize. The number is: 200,000,000.

14 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 EL LO Please take a moment to write your name in binary.

15 Images: Images are broken into pixels. Each color is given a number. Blue = 0, Light blue = 1, red = 2, white = 3 0001000110 00 11 0001000110 11 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 how long a row is elsewhere.) 000001110001000110101000000000 111111000100011010101111111111 111110101010101010

16 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 11111100

17 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.

18 Huffman coding CharFreqCode space7111 a4010 e4000 f31101 h21010 i21000 m20111 n20010 s21011 t20110 l111001 o100110 p110011 r111000 u100111 x110010 To encode, we replace each character with its Huffman code. The word “tree” is originally 01010100 01010010 01000101 01000101 Replacing it with the codes, we get: 011011000000000

19 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.

20 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.

21 Lossy compression

22 Credits Maru the cat http://catsnco.wordpress.com/2011/10/19/i- am-maru/ http://catsnco.wordpress.com/2011/10/19/i- am-maru/ Huffman tree http://en.wikipedia.org/wiki/Huffman_coding http://en.wikipedia.org/wiki/Huffman_coding Lossy compression NMR http://nmr.cemhti.cnrs- orleans.fr/Dmfit/Howto/Top/Default.aspx http://nmr.cemhti.cnrs- orleans.fr/Dmfit/Howto/Top/Default.aspx


Download ppt "Data storage Charles McAnany. What are the ones and zeroes? Hard drive Computer "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod."

Similar presentations


Ads by Google