1 / 370

CS 16 – Jan. 12

CS 16 – Jan. 12. Definition of computer & CS Making good decisions Computer organization A little history. Computer definition. An electronic device that can retrieve, store and process data You can do these things too! What is the difference?. Computer science.

garth-west
Télécharger la présentation

CS 16 – Jan. 12

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. CS 16 – Jan. 12 • Definition of computer & CS • Making good decisions • Computer organization • A little history

  2. Computer definition • An electronic device that can retrieve, store and process data • You can do these things too! • What is the difference?

  3. Computer science • Systematic study of how we … • solve problems • represent & manipulate information • Computer has large memory and fast “brain” – ideal for testing theories

  4. Good decisions • Correct (not misleading) • Relevant • Significant (don’t play weak cards) • Complete/thorough • Consider alternatives, suggest future work • Reasonable • Balance between acceptable & ideal

  5. Computer organization • Definition gives hint on how a computer is organized… • Retrieve/store data: computer’s memory • Process data: the CPU • Communication is also essential • I/O devices • network

  6. CPU Memory Peripherals network Helps us interact with the machine Gives it soul or behavior Translates to/from machine language Hardware vs. Software

  7. CS 16 – Jan. 14 • A little history • Introduce binary numbers

  8. Before 1940s • Only analog machines, moving parts • Specific purpose • Adding machines • Tabulators • Sunrise/sunset, celestial • General computing only theoretical interest • Alan Turing

  9. 1940s • Code-breaking machines in WW 2 • General purpose electronic computers • ENIAC, U. of Pennsylvania • ABC, Iowa State • Z3, Konrad Zuse in Germany • Transistor (1947) to have impact later • von Neumann concept forms basis of computer organization

  10. US Army photo

  11. 1950s & 1960s • Commercially produced computers (IBM) • gradually become more common in industry • Programming languages developed to facilitate commands to the machine • Colleges begin to teach computing • Large and expensive • Moore’s Law

  12. 1970s & 1980s • Integrated circuit (1971) allows computers to become much smaller • Intel chips 4004, 8008, 8086, 80286, etc. • Personal (home) computing • Applications for non-specialists • Intense competition • Internet only used in large companies, universities

  13. 1990s & 2000s • Computer for communication and mass medium • Internet as a virtual library & soapbox • Tech companies (Apple, Microsoft, Intel, Nokia,…) mature and gain clout • Growing need to manage information

  14. Binary Numbers • Binary = “base 2” • The “2” means each bit is either 0 or 1 • To interpret a binary number, use place value system.

  15. Place value system • In base 10, what does 278 mean? • 278 = 2 * 102 + 7 * 101 + 8 * 100 • Each digit corresponds to a power of 10

  16. Binary example • So now let’s try base 2: What is 11010? 1 * 24 + 1 * 23 + 0 * 22 + 1 * 21 + 0 * 20 • More concise to simply say 24 + 23 + 21

  17. 20 = 1 21 = 2 22 = 4 23 = 8 24 = 16 25 = 32 210 ~ 1 thousand 220 ~ 1 million 230 ~ 1 billion 240 ~ 1 trillion Powers of 2

  18. Binary  Decimal • In a binary number, each “1” gives you a power of 2 • More examples: 11 101 110 1110

  19. Questions • Let’s say we have 4 bits. • What is the lowest number? • What is the highest number? • Try same experiment with 5 bits.

  20. CS 16 – Jan. 16 • Interpreting binary  decimal √ • Decimal  binary • Shorthand ways of expressing binary • Octal • “Hex” • Negative numbers

  21. Number of Possible Values • 1 bit: 0 and 1 • 2 bits: 00, 01, 10, 11 • 3 bits: 000, 001, …? • For a given number of bits, how many patterns?

  22. decimal  binary • You already know binary  decimal • But given a decimal number like 45, what is binary form? • Binary numbers are longer than decimal. • (Ex. 5 digit number may require 15 bits) • My technique is the “binary store”

  23. Binary store • At the Binary Store, price is a power of 2: $1, $2, $4, $8, $16… • If you had $45, what could you buy? • 45 = 32 + 8 + 4 + 1 • Write powers of 2: 25 + 23 + 22 + 20 • Write binary number: 101101

  24. Another example • Let’s convert 61 to binary: • Go to binary store with $61… 61 = 32 + 16 + 8 + 4 + 1 61 = 25 + 24 + 23 + 22 + 20 Finally: 111101

  25. Octal • Octal means base 8: each digit is a power of 8. • Because 8 = 23, each octal digit corresponds to 3 bits • 4618 = 100 110 0012 • 73258 = ?

  26. Hexadecimal (“hex”) • Base 16: each digit is a power of 16 • Since 16 = 24, each hex digit corresponds to 4 bits. • Hex also means we have 16 different digits. • a = 10, b = 11, c = 12, d = 13, e = 14, f = 15

  27. Hex examples • 96416 = 1001 0110 01002 • d12316 = 1101 0001 0010 00112 • Now let’s go the other way: • 1110002 = ______16 • 100111112 = _______16

  28. Decimal  octal, hex • Often the best way to come up with octal or hex is to go thru binary first. • Ex. What is 71 in octal? • Binary store gives: 71 = 64 + 4 + 2 + 1 • Binary number is 1000111 • Grouped as octal: 001 000 1112 = 1078 • We can check answer.

  29. Why couldn’t the computer scientist tell the difference between Halloween (Oct 31) and Christmas (Dec 25) ?

  30. Negatives? • We can used a “signed” representation. • We want half the rep’ns to be negative. • Ex. 5 bits  32 numbers. • 16 numbers are negative • Thus, range is –16 to +15. • For n bits: range is –2n–1 to 2n – 1 – 1

  31. How to represent negatives • In ordinary (unsigned) binary, this was impossible! • In signed: 3 steps to represent –x: • Find rep’n of +x. • Invert the bits. • Add 1. • Try some examples.

  32. CS 16 – Jan. 21 Chapter 3: data representation • Many kinds of data  all in binary • Today: integers • Unsigned • Signed • Later: text, images, code, etc.

  33. Different kinds of data!

  34. Converting to binary • A computer system has both HW & SW • HW: only understands binary • SW: Translates human information into binary for the HW. • How? • Break into pieces (digits, words, letters, symbols, pixels, …) • Each piece individually gets a binary number.

  35. Data vs. information • What does 29613 mean to you? Or is it just a random number? • What might 111010110101110010… mean to the computer? • Information means that we are adding “meaning” to the data • Binary is like the alphabet… all languages use it to give meaning to letters. What is “pet set” ?

  36. Analog is how WE understand the world Just “warmer” or “crooked” is enough for us Can handle “in between” values Think of a clock, speedometer, odometer Digital emphasizes exact values, usually expressed as 0 or 1, true or false. No such thing as “in between.” It’s either 10:30 or 10:31… Analog vs. Digital

  37. An analogy Think of the notes on a piano. • 88 keys • Range: from lowest to highest key. • Granularity: distance between consecutive notes. • But for computer, notes are converted to binary numbers!

  38. Representations • To represent anything in binary, need to know: • Number of bits? (size) • What do the bits mean? (scheme) • Representation schemes for integers: • unsigned • signed • sign magnitude • BCD

  39. Size of rep’n • Most often 8, 16, or 32 bits • For our examples, we’ll use small sizes • 5 bits: 25 different numbers • 32 bits: 232 different numbers

  40. Scheme I: Unsigned • Ordinary binary number.  • For 5 bits: smallest = 00000 (zero) largest = 11111 (31) • In general, smallest = 0, largest = 2n – 1. • Going beyond possible range: “overflow”

  41. Review: Scheme II: Signed • Allows for negative numbers • We want half the rep’ns to be negative. • Ex. 5 bits  32 numbers. • 16 numbers are negative • Thus, range is –16 to +15. • For n bits: range is –2n–1 to 2n – 1 – 1

  42. Review: How to represent negatives • In unsigned, impossible! • In signed: 3 steps to represent –x: • Find rep’n of +x. • Invert the bits. • Add 1. • Try some examples.

  43. Closer look at signed • In 5 bits: largest number is 01111 (+15) lowest number is 10000 (–16) • Leftmost bit is “sign bit” • Positive #’s have same rep’n as unsigned. • Technique for –x doesn’t work for –16.

  44. Recap example • What does 110010 represent if interpreted as: • 6 bit unsigned? • 6 bit signed?

  45. Scheme III: Sign-magnitude • Leftmost bit works like a +/- sign. • Remaining bits behave like unsigned. • Example: what is 11001 ? • Leftmost bit “1” means number is negative • Remaining bits are 1001 = 9, so entire number is –9 • What would –20 look like in 8 bits? • +20 looks like 10100 or 00010100 • To make it negative, change first bit to 1.

  46. Scheme IV: BCD • “Binary Coded Decimal” • Only good for positives. • Each decimal digit corresponds to 4 bits. • Easy conversion for binary  decimal • Ex. 278 = 0010 0111 1000 • If we have 8 bit BCD, what is the range? • Waste

  47. Having enough bits • Question – Are 6 bits sufficient to represent the number 50? • Answer – Depends on the rep’n scheme. Let’s look at each one.

  48. CS 16 – Lab #2 Excel • values and formulas • Awesome number cruncher • Slick functions: sort, subtotals, charts • Can help answer probing questions • White pages = reading • Yellow pages = lab • Only one thing I don’t like about Excel…

  49. Bill Gates – Microsoft

More Related