1 / 22

Data storage

Data storage. Charles McAnany. What are the ones and zeroes?. " 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 . Computer.

shakti
Télécharger la présentation

Data storage

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data storage Charles McAnany

  2. What are the ones and zeroes? "Loremipsum dolor sit amet, consecteturadipisicingelit, sed do eiusmodtemporincididuntutlabore et dolore magna aliqua. Utenim ad minim veniam, quisnostrud exercitation ullamcolaboris. Computer Hard drive 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. Hundreds place Thousands place Tens place Ones place Sixteens place Eights place Twos place Fours place Ones place 1576 10110

  5. Converting from binary to decimal Sixteens place Eights place Twos place Fours place Ones place 10110 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. 1577 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 Largest power of two that fits: 512 553 - 512 = 41 Mark the 512 spot, and continue with 41.

  9. 41 Largest power of two that fits: 32 41 - 32 = 9 Mark the 32 spot, and continue with 9.

  10. 9 Largest power of two that fits: 8 9 - 8 = 1 Mark the 8 spot, and continue with 1.

  11. 1 Largest power of two that fits: 1 1 - 1 = 0 Mark the 1 spot, the number is zero, so you’re done.

  12. 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 E L L O • Please take a moment to write your name in binary.

  15. Glue the rows together. (remembering how long a row is elsewhere.) Images: Images are broken into pixels. 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 000001110001000110101000000000111111000100011010101111111111111110101010101010 Each color is given a number. Blue = 0, Light blue = 1, red = 2, white = 3

  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 • 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 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/ • Huffman tree http://en.wikipedia.org/wiki/Huffman_coding • Lossy compression NMR http://nmr.cemhti.cnrs-orleans.fr/Dmfit/Howto/Top/Default.aspx

More Related