1 / 119

Quiz on Ch.2

Quiz on Ch.2. Convert 20102 3 to decimal. Chapter 03. Data Representation. Data and Computers. Computers are multimedia devices,dealing with a vast array of information categories Computers store, present, and help us modify Numbers Text Audio Images and graphics Video.

Download Presentation

Quiz on Ch.2

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. Quiz on Ch.2 Convert 201023 to decimal

  2. Chapter 03 Data Representation

  3. Data and Computers Computers are multimedia devices,dealing with a vast array of information categories Computers store, present, and help us modify • Numbers • Text • Audio • Images and graphics • Video

  4. Data compression Reduction in the amount of space (memory) needed to store the data Measured by the Compression ratio = The size of the compressed data divided by the size of the original data Example: Two files are compressed with the ZIP utility: • One is originally 200 MB, and becomes 150 MB after compression • The other is originally 15 MB, and 11 MB after compression Which file is better compressed?

  5. Quiz A video file is originally 3.5 GB long. We compress it to 490 MB. What is the compression ratio?

  6. Data compression The Compression ratio is always between 0 and 1 (between 0% and 100%) Compression techniques can be Lossless → the data can be retrieved without any loss of the original information Lossy → some information may be lost in the process (but it doesn’t matter for the purposes of the intended application)

  7. Analog vs. Digital Many quantities of interest in the real-world are infinite and continuous • Zeno’s paradox: “That which is in locomotion must arrive at the half-way stage before it arrives at the goal.” — Aristotle, Physics VI:9 But computers are finite and discrete! How do we represent an infinite and continuous quantity in a computer? Answer: We approximate → represent only enough to satisfy our computational needs and our senses of sight and sound.

  8. Information can be represented in one of two ways: analog or digital Analog data A continuous representation, similar to the actual information it represents Digital data A discrete representation, breaking the information up into separate elements

  9. Analog and Digital Information Computers cannot work well with analog data, so we digitize the data Digitizing = Breaking data into pieces and representing those pieces separately, by using a finite number of binary digits Fine distinction: there are two operations performed: • one in time (a.k.a. sampling) • the other in amplitude (a.k.a. quantizing) Explain on thermometer, using a waveform example!

  10. Quiz A digital thermometer has a scale from 50 to 100 degrees (F). The temperature is represented on 7 bits. What is the smallest temperature difference that it can measure?

  11. Analog and Digital Information Why do we use binary to represent digitized data? • Price: transistors are cheap to produce • Remember Babbage! • Reliability: transistors don’t get jammed • Remember Babbage!

  12. Figure 3.2An analog and a digital signal Electronic Signals Important facts about electronic signals • An analog signal continually fluctuates in voltage up and down • A digital signal has only a high or low state, corresponding to the two binary digits

  13. Figure 3.3Degradation of analog and digital signals • All electronic signals (both analog and digital) degrade due to absorption in transmission lines • The amplitude (voltage) of electronic signals (both analog and digital) fluctuates due to environmental effects, a.k.a. noise The difference is that digital signals can be regenerated!

  14. Binary Representations One bit can be either 0 or 1 • One bit can represent two things Two bits can represent four things (Why?) How many things can three bits represent? How many things can four bits represent?

  15. Why does the number of combinations double with every extra bit?

  16. Binary Representations How many things can n bits represent? What happens every time you increase the number of bits by one? EoL

  17. Binary Representations How many things can n bits represent? Reversing the problem: How many bits are needed to represent N things? • All desktops in this lab

  18. QUIZ How many bits are needed to represent all the courses you’re planning to take in college?

  19. 3.2 Representing Numeric Data Negative integers Signed-magnitude representation The sign represents the ordering, and the digits represent the magnitude of the number

  20. Negative Integers There is a problem with the sign-magnitude representation: plus zero and minus zero. • More complex hardware is required! Solution: Let’s not represent the sign explicitly! “Complement” representation

  21. Ten’s complement Using two decimal digits, represent 100 numbers • If unsigned, the range would be 0…? let 1 through 49 represent 1 … 49 let 50 through 99 represent -50 … -1

  22. Ten’s complement Top: representations (the “label on the jar) Bottom: the actual numbers that are being represented (the “content of the jar)

  23. QUIZ Given the following representations, find in each case what actual number is being represented: • 51 • 52 • 96 • 47

  24. EXTRA-CREDIT QUIZ If the representation is 76, what actual number is being represented?

  25. Why the “complement” in ten’s complement? 100 – 50 = 50 100 – 49 = 51 …………………….. 100 – 1 = 99 In general: 100 – I = representation of – I

  26. QUIZ What is the representation for each of these actual numbers? • -48 • -40 • -30 • -5

  27. Let’s use ten’s complement! To perform addition, add the numbers and discard any carry • Now you try it • 48 (signed-magnitude) • 1 • 47 • How does it work in • the new scheme?

  28. Adding two negative numbers Try these: 4 - 4 -4 - 3 +3 + -3

  29. Solve in notebook for next time: • End of chapter 27 through 31 • All examples and exercises presented in the slides so far (text up to p.61, incl.) – Make sure to ask next time if you have questions!

  30. Two’s Complement What do you notice about the left-most bit (MSB)?

  31. Two’s complement on 4 bits (k = 4)

  32. Two’s complement Addition and subtraction are the same as in unsigned: -127 1000 0001 + 10000 0001 -126 1000 0010 Ignore any Carry out of the MSB: -1 1111 1111 + -1 1111 1111 -2 1111 1110

  33. Two’s complement Formula to compute the negative of a number on k digits: • for ten’s comp: Negative(I) → 10k - I • for two’s comp: Negative(I) → 2k - I Practice: find the 8-bit two’s comp. representations of: -2 -51 + 128 (trick question!) - 129 (trick question!) 0 Warning: The example on p.62 has a typo: 28 is 256, not 128.

  34. QUIZ What is the 8-bit two’s complement representation of these numbers? • -13 • 40

  35. “Fast” two’s complement Easier way to change the sign of a number: Flip all bits, then add 1 Try it out! Find the negatives of the following two’s complement numbers: 0000 0011 1000 0000 1000 0001 1000 0011 1001 0110 1111 1111 This is how subtraction is implemented in computer hardware! A – B = A + (-B)

  36. QUIZ Perform the following operation in 8-bit two’s complement: 40 – 13

  37. What happens if the computed value won't fit in the given number of bits k? Overflow If k = 8 bits, adding 127 to 3 overflows 1111 1111 + 0000 0011 0 1000 0010 … but adding -1 to 3 doesn’t! Conclusion: overflow is specific to the representation(unsigned, sign-mag., two’s comp., floating point etc.)

  38. Overflow is something we should expect when mapping an infinite world onto a finite machine!

  39. Trick QUIZ What decimal number does this binary number represent? 1001 1110

  40. Solve in notebook for next time: End of chapter 33, 40

  41. Representing Real Numbers Real numbers A number with a whole part and a fractional part 104.32, 0.999999, 357.0, and 3.14159 Positions to the right of the decimal point are the fractional part (tenths, hundredths, thousandths etc.): 10-1, 10-2 , 10-3 …

  42. Binary fractions Same rules apply in binary as in decimal Decimal point is actually the radix point Positions to the right of the radix point in binary are 2-1 (one half) = 0.5 2-2 (one quarter) = 0.25 2-3 (one eighth) = 0.125 …

  43. Converting fractions from binary to decimal Easy! Just multiply with the powers of 2, as we did for unsigned binary. Only difference is that now the powers are negative. Example: .10012 = 0. 10

  44. QUIZ Convert: .10112 = 0. 10

  45. Converting fractions from decimal to binary Remember the repeated divisionalgorithm? We apply it for the integer part of the number. To covert the fractional part, we use the repeated multiplicationalgorithm! Example: 0.43510 = 0. 2

  46. QUIZ Convert: 0.310 = 0. 2

  47. QUIZ Finite decimal fractions may have infinite binary representation! 0.310 = 0. 0100110011 2 Stop after 8 bits!

  48. In general, we use “sign-mantissa-exponent” R =  mantissa * 10exp R =  mantissa * 2exp Depending on the form of the mantissa, we have: Floating-point notation Scientific notation Representing Real Numbers

  49. Floating point In the mantissa, the radix point is always at the extreme right! This representation is called floating point because, although the number of digits is fixed (5 in the example above), the radix point floats (according to the exponent)

  50. Not in text! Floating point in binary? It does exist - remember floating point numbers in Python! It can be implemented either through software, or directly in the hardware of the computer. Until 1989, all desktops had an optional chip, separate from the main CPU, called FPU (a.k.a. math coprocessor). The Intel 80486, introduced that year, had the first integrated CPU + FPU. 80486 was also the first chip with over 1 million transistors!

More Related