1 / 30

Representing concepts, Part 1

What we’ll cover for Part 1 : Representing concepts in a computer Five concept types Numbering systems: additive positional How to represent our decimal number values in a computer containing on-off switches. Representing concepts, Part 1. Power Tools.

azia
Télécharger la présentation

Representing concepts, Part 1

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. What we’ll cover for Part 1 : Representing concepts in a computer Five concept types Numbering systems: additive positional How to represent our decimalnumber values in a computer containing on-off switches Representing concepts, Part 1 Power Tools

  2. How do humans represent concepts? Examine: Annual earnings of a UNC-CH faculty member. Script of Gone with the Wind. Set of fingerprints found in a police department. Tarzan yell. Recipe for making chicken fajitas. Five basic kinds of concepts (data/information) Want a single, common way to represent all five. Can be encoded as numbers; which in turn can appear as signals at the hardware level. Representing concepts

  3. Representing numeric values Additive:  / / / / / Are any systems we use additive? Can some symbols have a face value other than 1? • Positional: • Face value • Unique symbols: represent elementary quantities. • Place value • Value determined by positionitoccupies. • Base determines how many unique symbols are used. • Raising the base to all its powers gives the place value. • Total value:face value * place value.

  4. Counting with ten fingers(& Arabic numbers) 0 1 2 3 4 5 6 7 8 9 --Symbols represent values from 0 through 9. --How do we represent values greater than 9? Use other symbols? --Base? 104 103 102 101 100 powers base place values 10,000 1,000 100 10 1 2 3 1 4 1 3 7 8 6 0 How would you describe your algorithm to find the total value of each number?

  5. Suppose, we count with only 5 fingers... Symbols? WHAT has changed?? What remains same?? powers b4 b3 b2 b1 b0 base place values 625 125 25 5 1 2 1 1five = ??ten 4 0 3five = ??ten • Notice base notation: numberbase • Decimal is most common, so may omit base notation. 0 1 2 3 4 Suppose, we count with only 2 fingers... Base? Number of symbols? Quiz: How would you represent the value 2?

  6. powers base place values 26 25 24 23 22 21 20 64 32 16 8 4 2 1 Notice as you read down, looks somewhat like an advancing odometer: 0 1 1 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 Note 0 as “place holder” for the least significant digits with 0 value.

  7. 105 104 103 102 101 100 powers base place values Samething for base ten: 100000 10000 1000 100 10 1 0 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 ... 2 0 ... 9 9 ... 1 0 0

  8. What determines numberof unique symbolsused in a positional numbering system, then? What determines value of each position? Here’s a number: 1110 What value does it represent? (what is its decimal equivalent?) But WAIT!…what’s the problem here? Positional systems

  9. 10,000 1,000 100 10 1 Base 10place values: Base 5place values: 625 125 25 5 1 Base 2place values: 16 8 4 2 1 1 1 1 0base x Face values: Base x: Base 10: Base 5: Base 2: Dec. Value: Same algorithm: Sum of (face*place) = 1*1000+1*100+1*10+0*1= 1,110 1* 125+1*25+1*5+0*1= 155 1* 8+1* 4+1*2+0*1= 14

  10. Even more fingers…….Hexadecimal powers base place values face values • Base 16: quick---how many fingers…or symbols? • 0 1 2 3 4 5 6 7 8 9 A B C D E F 101112131415dec value BEEF16What is its decimal equivalent? 164 163 162 161 160 65,536 4,096 256 16 1 B E E F 16 2 A D = 68510 What algorithm do you use to find total value? 48,87910 11*4096 + 14*256 +14*16 +15*1= 10

  11. Hexadecimal ... used by Programmers! HEX BI HEX BI HEX BI HEX BI 0 0000 4 0100 8 1000 C 11001 0001 5 0101 9 1001 D 11012 0010 6 0110 A 1010 E 11103 0011 7 0111 B 1011 F 1111 • for “looking” at the actual bits that are stored in memory (e.g. memory dump) • for “specifying” binary data. HEXadecimal is an efficient shorthand notation for Binary • one HEX symbol specifies 4 bits 01101110 = 6E 11111111 = FF

  12. These are legal in their respective bases: A489C16 356728 24415 These are not: why? 87728 3A576910 112112 QUOTABLE Positional values • Base affects value! (place values change) • 324510 is not equal to 32456 • But: 1510 = 11112 = F16

  13. Simple to convert from any base to a decimal base; or from a decimal base to another base • Converting a base-x number to a decimal number e.g.:2134 = ?10 powers base place values (face values) • first, find place values (how???) 43 42 41 40 64 16 4 1 2 1 34 • second, find total values (how???) Tot Value = SUM of (each face value * each place value) 2*16 + 1*4 +3*1 = 39

  14. first, determine symbols (face values) used in base x. (How?) Converting a decimal number into base-x number powers base place values face values 26 25 24 23 22 21 20 64 32 16 8 4 2 1 • second, find place values for base x. (How?) • Start far left as reasonable, and try largest face value: does it fit? If so, fill in. If not, try next smallest face value. Repeat. • In other words: Fill in table with enough numbers until it totals desired decimal value--sort of reversing the algorithm. Example: 3710 is represented how in base two? --Symbols in base two? (face values) --Place values? --Fill in table, starting left ... 1 0 0 1 0 1

  15. Get with 1 or 2 neighbors: Try these now: (a) Convert 12123 to a base 10 number (b) Convert 45 to a base 2 number (c) Convert 45 to a base 4 number

  16. powers base place values (a) Convert 12123 to a base 10 number 12123 = ?10 34 33 32 31 30 81 27 9 3 1 1 2 1 23 1*27 + 2*9 + 1*3 + 2*1 = 50

  17. powers base place values --We KNOW the place values. --We are LOOKING for correct FACE values to plug in to the table! --1st: What symbols can we use in this base? --2nd: Where should we place which symbols in the table (until it equals our total of 45)? Start left, trying largest face value….work your way right. 16 (a) Convert 45 to a base 2 number 4510 = ?2 26 25 24 23 22 21 20 64 3216 8 4 2 1 1 0 1 1 0 1

  18. powers base place values --We KNOW the place values. --We are LOOKING for correct FACE values to plug in to the table! --1st: What symbols can we use in this base? --2nd: Where should we place which symbols in the table (until it equals our total of 45)? Start left, trying largest face value….work your way right. 17 (a) Convert 45 to a base 4 number 4510 = ?4 45 44 43 42 41 40 1024256 64 16 4 1 2 3 1

  19. To represent an integer value in somebasex, how many correct answers are there? 1310 = ?x for x ranging from 2 to infinity 1310 = 11012 1310 = 167 1310 = 1112 1310 = 1113 1310 = 158 1310 = 1013 1310 = 314 1310 = 149 1310 = D14 1310 = 235 1310 = 1310 1310 = D15 1310 = 216 1310 = 1211 1310 = D16 ...

  20. Divide decimal number by base number X. Write the quotient Write the remainder by the side Keep dividing as long as quotient isn’t zero. Read answer from remainder side in reverse order. quotient remainder • Can also use a division algorithm to convert a decimal number to some base x number. example 4410 = ?2 1 0 1 1 0 0 44/2 = 22 /2 = 11 /2 = 5 /2 = 2 /2 = 1 /2 = 0 0 0 1 1 0 1

  21. Base 10: DECImal numbering system Base 2: BInary numbering system Any base number can be converted to binary. But WHY BINARY? …. 1.0 9 8 1 7 6 Voltage 5 4 3 0 2 1 0 0 Binary Decimal

  22. So how do we represent a bit “in the box”? 8 4 2 1 (place values) 1 = 0 0 0 0 = 0 = 0 0 0 1 = 0 0 1 0 = 0 0 1 1 = 0 1 0 0 • Logical structure, then: • Binary 0s and 1s: Binary digits. Bits. • Bit: smallest, most basic data unit in a computer. 0 1 2 3 4 Etc?

  23. Binary numbers: general & powerful common representation for all these types: Appear as on/off signals at the hardware level (physical structure) Numeric values Characters Visual Audio Instructional Encode as binary numbers (logical structure) 0 1

  24. Whole numbers (pos & neg): we generally use a fixed # of bits. 32 bits allows for a positive value of >2 billion. #bits#possib’s 121 2 222 4 424 16 828 256 16216 65536 32232 4,294,967,296 (~half positive) Numeric values in binary systems

  25. We use special mathematical conventions to represent negative numbers and fractions. • The details are shown on the following two slides, but are just for culture.

  26. Two’s complement notation fixed # digits to represent each whole number (eg. 6 used here) zero: all 0’s (000 000) positive numbers: like before, but have leading 0’s 510 000 1012 finding a negative number: take complement and add 1: - 510 - 000 1012 111 0102 + 000 0012  111 0112 1bit 15 bits  number 5 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 -5 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 16 bits number 5 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 -5 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 Negative numbers • Excess notation • sign = most significant bit • not generally used

  27. 1bit 8 bits 23 bits e+127 m  0 1 0 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = 5.75 Floating point notation • Fixed pointnotation • add a decimal point: • Floating point notation is used to represent fractions. (Or real numbers with a limited precision.) • high order bit is sign bit • remaining bits used for exponent and mantissa • decimal point placed to left of mantissa; exponent shifts radix 23 22 21 20 2-1 2-2 2-31 0 1 1 . 0 1 1 = 8 + 2 + 1 + 0.25 + 0.125 = 11.375 (1+m)2e

  28. Think of repeating decimals: what’s the problem here? 1/3 = 0.3333333... The same thing can happen in binary, but with different numbers. Converting back and forth with a fixed number of places, we can end up with unexpected round-off errors. Experiment: try 1  3 (press =)  3 on different calculators. Digression: Limitations on precision

  29. So what’s an important POINT here?

  30. Recall a question from Lec-01 overview: • How can hardware that can represent only whole number values (with on/off switches) be used to represent more complex data values (real numbers, negative numbers, …)? ANSWER? New data types can be defined—similarto the way that complextransformations can be defined—by software. • The rules people define for transforming data will depend on the representations that we choose for the data. • We’ll soon see how other kinds of complex data are represented.

More Related