Successfully reported this slideshow.
Upcoming SlideShare
×

# [1] Data Representation

Unit 1 Data Representation from Computer Systems Unit of Higher Computing

• Full Name
Comment goes here.

Are you sure you want to Yes No

### [1] Data Representation

1. 1. Data Representation Represent! How information is stored in a Computer System With our resident Binary enthusiast … Brian Sup Homies! only 10 people understand binary Mr McAlpine Hamilton Grammar School
2. 2. <ul><li>A computer is a two state machine (using only 1’s and 0’s to represent digits ‘on’ and ‘off’ </li></ul><ul><li>Represented using voltage ( 1 – 5 volts is ON! 0 volts … surprise OFF!) </li></ul><ul><li>Binary System 1’s and 0’s </li></ul><ul><li>To + - * / fewer rules need to be built into processor </li></ul><ul><li>Drop in voltage - NO EFFECT </li></ul><ul><li>Easy to represent two stages in storage devices (presence of pits on a CD-ROM) </li></ul>Binary... Why do computers use it?
3. 3. <ul><li>Use 1’s and 0’s to represent decimal numbers </li></ul>Binary... only ten people know it no ... wait ... <ul><li>A BIT (1 OR 0) is the smallest unit of memory in a computer </li></ul><ul><li>1 bit – 1 or 0 ( two different numbers ) </li></ul><ul><li>2 bits – 00, 01, 10, 11 ( four numbers ) </li></ul><ul><li>3 bits – 000, 001, 010, 011, 100, 101, 110, 111 – ( 8 different numbers ) </li></ul>
4. 4. Are you getting it yet? <ul><li>How many different numbers can you represent with? </li></ul><ul><ul><li>4 bits? </li></ul></ul><ul><ul><li>5 bits? </li></ul></ul><ul><ul><li>6 bits? </li></ul></ul><ul><ul><li>8 bits? </li></ul></ul><ul><li>Can easily work it out by … </li></ul><ul><li>Number of bits ^ 2 </li></ul>
5. 5. <ul><li>Taking an example using 8 bits </li></ul><ul><li>256 individual combinations we can make </li></ul>What does it all mean? <ul><li>128 64 32 16 8 4 2 1 </li></ul>0 0 0 0 0 0 0 0 <ul><li>Lowest number we can represent </li></ul>1 1 1 1 1 1 1 1 <ul><li>Highest number we can represent </li></ul><ul><li>We simply add up the numbers with a 1 </li></ul><ul><li>128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 </li></ul>
6. 6. <ul><li>We want to represent the number 83 in binary </li></ul><ul><li>(there’s a couple of ways of working it out) </li></ul>the other way around <ul><li>128 64 32 16 8 4 2 1 </li></ul>0 (coz 128 don’t fit!) 1 ( 64 fits, leaves 19 ) 0 1 (leaves 3 ) 0 0 Gives us 1 ( 1 left) 1 0 1 0 1 0 0 1 1
7. 7. Ok idiots, give this a go <ul><li>Convert these from binary to decimal </li></ul><ul><li>0110 0111 </li></ul><ul><li>1110 0011 </li></ul><ul><li>0101 0110 </li></ul><ul><li>1010 1100 </li></ul><ul><li>Convert these decimals to binary </li></ul><ul><li>255 </li></ul><ul><li>84 </li></ul><ul><li>172 </li></ul><ul><li>4 </li></ul><ul><li>128 64 32 16 8 4 2 1 </li></ul>
8. 8. Challenge – 12 bits <ul><li>Convert these from binary to decimal </li></ul><ul><li>1001 0110 0111 </li></ul><ul><li>0101 1110 0011 </li></ul><ul><li>1011 0101 0110 </li></ul><ul><li>1101 1010 1100 </li></ul><ul><li>128 64 32 16 8 4 2 1 </li></ul>
9. 9. Right, so that’s easy <ul><li>Not great, it doesn’t let us represent </li></ul><ul><li>Negative Numbers </li></ul><ul><li>Fractions of numbers </li></ul><ul><li>Two’s Compliment </li></ul><ul><li>Floating Point Representation </li></ul>
10. 10. Two’s Compliment <ul><li>Allows us to represent negative numbers </li></ul><ul><li>Need a way of recognising if a number is negative </li></ul><ul><li>Two’s Compliment does thus </li></ul><ul><li>Take positive binary number 0000 1010 +10 </li></ul><ul><li>Invert all bits 1111 0101 </li></ul><ul><li>ADD 1 ( 1 + 1 = 0, carry over) 1111 0110 -10 </li></ul><ul><li>Anyone work out how you know if it’s a negative number? </li></ul>
11. 11. Remember! <ul><li>To check which number representation we are using! If a question doesn’t tell you choose one yourself and write it down! </li></ul><ul><li>Convert to two’s compliment representation </li></ul><ul><li>-9 </li></ul><ul><li>-45 </li></ul><ul><li>-187 </li></ul><ul><li>-283 </li></ul>
12. 12. The good thing! <ul><li>When we are trying to check what a number is in decimal we just repeat the process! (that’s why two’s compliment is so good) </li></ul><ul><li>What are these numbers in decimal? </li></ul><ul><li>1000 1101 </li></ul><ul><li>1111 0110 </li></ul><ul><li>1010 1010 </li></ul><ul><li>1100 0011 </li></ul>
13. 13. More good bits <ul><li>We used to use a signed bit to represent a negative number </li></ul><ul><li>This reduce the number of bits available to represent the number </li></ul><ul><li>This would have reduced the range of numbers which could be represented </li></ul><ul><li>Computer Arithmetic was “Pure Mental” </li></ul>
14. 14. <ul><li>23.75 = 0.2375 * 10 ^ 2 </li></ul><ul><li>2375 – the mantissa </li></ul><ul><li>2 – the exponent </li></ul><ul><li>The same thing in binary </li></ul><ul><li>Mantissa gives the number to be represented </li></ul><ul><li>The exponent gives how many places to “float” the decimal point </li></ul>Real Numbers! We've got negative, now fractions
15. 15. Real Numbers <ul><li>Number 13.75 </li></ul><ul><li>8 4 2 1 0.5 0.25 0.125 0.0625 </li></ul><ul><li>1 0 1 1 1 0 0 </li></ul><ul><li>Mantissa = 1101.1100 </li></ul><ul><li>Exponent (need to move 4 decimal places) </li></ul><ul><li>8 4 2 1 </li></ul><ul><li>0 1 0 0 </li></ul><ul><li>Exponent = 0 1 0 0 </li></ul><ul><li>1101 1100 0100 (all we need) </li></ul>
16. 16. Increasing the M and the E <ul><li>Increasing the mantissa </li></ul><ul><li>Giving more bits to represent a number would increase the precision </li></ul><ul><li>Think of a tape measure </li></ul><ul><li>(if there are more wee bits marking the distances you will get a more precise measurement) </li></ul>
17. 17. Increasing the M and the E <ul><li>Increasing the exponent </li></ul><ul><li>This means that the range of the numbers is increased </li></ul><ul><li>10 * small exponent = small number </li></ul><ul><li>10 * big exponent (more bits) = bigger number </li></ul>Worksheet 1
18. 18. Questions and Reading <ul><li>From the Walsh Book Read </li></ul><ul><li>Pages – 2 to 9 </li></ul><ul><li>Questions (on page 20) </li></ul><ul><li>1 2 3 4 5 6 7 8 9 </li></ul>Worksheet 1
19. 19. Data Representation How text is represented/sent in a computer system ASCII Code UNICODE Memory Sizes Im the greatest Dancer!
20. 20. <ul><li>A byte is space which is used to store a character ( 8 bits ) </li></ul><ul><li>All the characters which can be represented are known as the character set </li></ul><ul><li>Each character to display is given a different code </li></ul><ul><li>ASCII is the most popular form </li></ul><ul><li>American Standard Code for Information Interchange </li></ul>Sending Text!
21. 21. What does it all mean? <ul><li>What’s in a bit? </li></ul><ul><li>A 1 or a 0 </li></ul>How should you remember it? <ul><li>Kinder Bueno </li></ul><ul><li>8 wee bits or one big Byte ! </li></ul>
22. 22. Memory Sizes <ul><li>Reminder </li></ul><ul><li>Big </li></ul><ul><li>Boys </li></ul><ul><li>Kicked </li></ul><ul><li>My </li></ul><ul><li>Granny </li></ul><ul><li>Twice </li></ul>
23. 23. Memory Sizes <ul><li>Bit <- smallest </li></ul><ul><li>Byte </li></ul><ul><li>Kilobyte </li></ul><ul><li>Megabyte </li></ul><ul><li>Gigabyte </li></ul><ul><li>Terabyte <- biggest </li></ul>
24. 24. <ul><li>A bit is the smallest unit of memory </li></ul><ul><li>There are 8 bits in a byte </li></ul><ul><li>There are 1024 bytes in a kilobyte </li></ul><ul><li>There are 1024 Kb in a Megabyte </li></ul><ul><li>There are 1024 Mb in a Gigabyte </li></ul><ul><li>There are 1024 Gb in a Terabyte </li></ul>Memories at the corner of my eye!
25. 25. Calculating Memory Sizes <ul><li>We don’t say our broadband speed is </li></ul><ul><li>33 million bits per second </li></ul><ul><li>4 Megabytes </li></ul><ul><li>We don’t say our computer has </li></ul><ul><li>687194767360 bits of memory </li></ul><ul><li>80 Gigabytes </li></ul><ul><li>Calculating the correct sizes is a wee bit fidgety but you get used to it </li></ul>
26. 26. Calculating Memory Sizes <ul><li>bits / 8 </li></ul><ul><li>bytes / 1024 </li></ul><ul><li>kilobytes / 1024 </li></ul><ul><li>megabytes / 1024 </li></ul><ul><li>gigabytes / 1024 </li></ul><ul><li>terabytes </li></ul><ul><li>TAKE A NOTE </li></ul>Terabytes * 1024 Gigabytes * 1024 Megabytes * 1024 Kilobytes * 1024 Bytes * 8 bits TAKE A NOTE Worksheet 3
27. 27. ASCII Code <ul><li>ASCII is a 7 bit code which allows 128 characters </li></ul><ul><li>Extended ASCII allows 8 bits or 256 characters </li></ul><ul><li>Used to represent text although some characters don’t print </li></ul><ul><li>0 – 31 are what is known as control characters </li></ul><ul><li>Carriage Return, Tab, Clear Screen for example </li></ul>
28. 28. UNICODE <ul><li>What about the CODES that ASCII cannot represent? The Japanese for example </li></ul><ul><li>UNICODE is a 16 bit code which is used to represent a lot more characters </li></ul><ul><li>ASCII uses less memory (7 bits) </li></ul><ul><li>UNICODE capable of representing a lot more characters </li></ul>
29. 29. ASCII Code <ul><li>65 in decimal = A </li></ul><ul><li>66 = B </li></ul><ul><li>67 = C and so on and so forth </li></ul><ul><li>We can code messages and understand what they say etc </li></ul><ul><li>I intercepted a nasty text from Mr Arthur to Mr McGowan help me out a bit </li></ul><ul><li>Have a bash at working out this message </li></ul>Worksheet 2
30. 30. Data Representation Graphics How are Graphics stored in a Computer System Calculating memory requirements These glasses are X-Ray
31. 31. <ul><li>Graphics are made up of tiny dots called PIXELS each requiring one bit </li></ul><ul><li>Picture Elements 49 bits memory. WHY? </li></ul>GRAPHICS!
32. 32. Resolution <ul><li>A screen display of 800 x 600 is smaller is resolution </li></ul><ul><li>1024 x 768 is higher resolution </li></ul><ul><li>Two types of Graphic </li></ul><ul><li>Bit mapped </li></ul><ul><li>Vector </li></ul>
33. 33. Resolution <ul><li>A screen display of 800 x 600 is smaller is resolution </li></ul><ul><li>1024 x 768 is higher resolution </li></ul><ul><li>Two types of Graphic </li></ul><ul><li>Bit mapped </li></ul><ul><li>Vector </li></ul><ul><li>These store the graphics in different ways </li></ul>
34. 34. Bit Mapped <ul><li>Think about Paint </li></ul><ul><li>When you draw a shape on top of another it rubs out anything on the bottom </li></ul><ul><li>It has a fixed resolution (which means your image is rubbish when printed!) </li></ul><ul><li>You can zoom in and edit individual pixels </li></ul><ul><li>It saves the full screen – even if there’s nothing on there! </li></ul>
35. 35. Vector Graphics <ul><li>Keeps shapes as separate objects </li></ul><ul><li>Saves attributes of objects rather than all pixels – less memory requirements </li></ul><ul><li>Resolution Independence – prints at the full resolution available on printer </li></ul><ul><li>Can edit all the individual objects which make up the graphic, but not the individual pixels </li></ul>
36. 36. Backing Storage Requirements This image of screech measures 2 inches by 2 inches. It has a resolution of 80 dpi using 256 colours Memory Required Total Pixels (2 * 80) * (2 * 80) = 25, 600 Each pixel could be one of 256 different colours 256 requires 8 bits 25,600 * 8 = 204, 800 bits 204, 800 = 25,600 bytes or 25 kilobytes
37. 37. Your Turn This idiots picture measures 3 inches by 2 inches It has a resolution of 150 dots per inch. It uses TRUE COLOUR which uses 24 bits per pixel 395.5 Kilobytes Worksheet 4
38. 38. Data Representation The need for Compression Different methods of Compression Compress Yourself!
39. 39. Data Compression <ul><li>Compression simply means reducing the size of a file in order to save some space </li></ul><ul><li>Two different types </li></ul><ul><li>Lossy </li></ul><ul><li>Lossless </li></ul>
40. 40. Lossless Compression <ul><li>Means that none of the original data is lost </li></ul><ul><li>Counting repeating pixels is one method </li></ul><ul><li>This means you can save </li></ul><ul><ul><li>Store what colour pixel is </li></ul></ul><ul><ul><li>How many are repeated in a row </li></ul></ul><ul><ul><li>Saves a lot of memory </li></ul></ul>
41. 41. Lossy Compression <ul><li>Means you sacrifice some data to reduce the file size </li></ul><ul><li>Using complex mathematical coding </li></ul><ul><li>Ditching stuff our eyes cant see </li></ul><ul><li>Can reduce size more than lossless </li></ul><ul><li>But, only if it doesn’t make the file useless </li></ul>Worksheet 5
42. 42. Advantages of Compression <ul><li>Bit maps use up a lot of backing storage </li></ul><ul><li>Compression saves a lot of it </li></ul><ul><li>The less space it takes up the less time it takes to transfer it in an email etc </li></ul><ul><li>Takes less time to load up in a web browser </li></ul>
43. 43. Disadvantages of Compression <ul><li>If Lossy compression is used then detail may be lost from the images </li></ul><ul><li>Can alter the images introducing things that weren’t there </li></ul><ul><li>Take a lot of time to compress a very large image </li></ul><ul><li>Repeated compression can alter and affect the image </li></ul>
44. 44. And here it ends <ul><li>That’s everything in Section 1: Data Representation </li></ul><ul><li>What you need to do now: </li></ul><ul><li>Read Scholar for more in depth information </li></ul><ul><li>Read Walsh for the same </li></ul><ul><li>Practice loads of questions (Walsh Book) </li></ul><ul><li>Study for end of section test </li></ul>