Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMP 4—Power Tools for the Mind 1 What’s in the box? Representing concepts, Part 1 What we’ll cover for Part 1 : Representing concepts in a computer –Five.

Similar presentations


Presentation on theme: "COMP 4—Power Tools for the Mind 1 What’s in the box? Representing concepts, Part 1 What we’ll cover for Part 1 : Representing concepts in a computer –Five."— Presentation transcript:

1

2 COMP 4—Power Tools for the Mind 1 What’s in the box? 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 Power Tools

3 COMP 4—Power Tools for the Mind 2 What’s in the box? 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

4 COMP 4—Power Tools for the Mind 3 What’s in the box? 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 position it occupies. 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.

5 COMP 4—Power Tools for the Mind 4 What’s in the box? 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? base place values powers 10 4 10 3 10 2 10 1 10 0 10,000 1,000 100 10 1 2 3 1 7 8 6 0 4 1 3 How would you describe your algorithm to find the total value of each number?

6 COMP 4—Power Tools for the Mind 5 What’s in the box? Suppose, we count with only 5 fingers... Symbols? WHAT has changed?? What remains same?? base place values powers b 4 b 3 b 2 b 1 b 0 625 125 25 5 1 2 1 1 five = ?? ten 4 0 3 five = ?? ten Notice base notation: number base Decimal is most common, so may omit base notation. Suppose, we count with only 2 fingers... Base? Number of symbols? Quiz: How would you represent the value 2 ? 0 1 2 3 4

7 COMP 4—Power Tools for the Mind 6 What’s in the box? base place values powers 2 6 2 5 2 4 2 3 2 2 2 1 2 0 64 32 16 8 4 2 1 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 Notice as you read down, looks somewhat like an advancing odometer: Note 0 as “place holder” for the least significant digits with 0 value.

8 COMP 4—Power Tools for the Mind 7 What’s in the box? 100000 10000 1000 100 10 1 0 1 2 3 4 5 6 7 8 9 base place values powers 10 5 10 4 10 3 10 2 10 1 10 0 Same thing for base ten: 1 0 1 1 1 2... 2 0... 9 9... 1 0 0

9 COMP 4—Power Tools for the Mind 8 What’s in the box? Positional systems What determines number of unique symbols used 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?

10 COMP 4—Power Tools for the Mind 9 What’s in the box? Base 10 place values: 10,000 1,000 100 10 1 625 125 25 5 1 Base 5 place values: 16 8 4 2 1 Base 2 place values: 1 1 1 0 base x Face values: Dec. Value: Same algorithm: Sum of (face*place) = Base x: Base 10: Base 5: Base 2: 1 * 1000 + 1 * 100 + 1 * 10 + 0 * 1 = 1 * 125 + 1 * 25 + 1 * 5 + 0 * 1 = 1 * 8 + 1* 1* 4 + 1 * 2 + 0*1 0*1 = 1,110 155 14

11 Even more fingers…….Hexadecimal –0 1 2 3 4 5 6 7 8 9 BEEF 16 What is its decimal equivalent? 16 4 16 3 16 2 16 1 16 0 base place values face values powers 65,536 4,096 256 16 1 B E E F 16 What algorithm do you use to find total value? 11*4096 + 14*256 + 14*16 + 15*1 = 4 8,879 10 A B C D E F 10 11 12 13 14 15 dec value Base 16: quick---how many fingers…or symbols? 2 A D 10 = 685 10

12 Hexadecimal... used by Programmers! 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 = 6E11111111 = FF HEX BI 000004010081000C1100 100015010191001D1101 2001060110A1010E1110 3001170111B1011F1111

13 COMP 4—Power Tools for the Mind 12 What’s in the box? Positional values These are legal in their respective bases: –A489C 16 –35672 8 – 2441 5 These are not: why? –8772 8 – 3A5769 10 –11211 2 QUOTABLE Base affects value ! (place values change) –3245 10 is not equal to 3245 6 –But: 15 10 = 1111 2 = F 16

14 COMP 4—Power Tools for the Mind 13 What’s in the box? 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.: 213 4 = ? 10 –first, find place values (how???) base place values (face values) powers 4 3 4 2 4 1 4 0 64 16 4 1 2 1 3 4 –second, find total values (how???) 2*16 + 1*4 + 3*1 = 39 Tot Value = SUM of (each face value * each place value)

15 COMP 4—Power Tools for the Mind 14 What’s in the box? Converting a decimal number into base-x number –first, determine symbols (face values) used in base x. (How?) –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: 37 10 is represented how in base two? -- Symbols in base two? (face values) --Place values? --Fill in table, starting left... base place values face values powers 64 32 16 8 4 2 1 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 0 0 1 0 1

16 COMP 4—Power Tools for the Mind 15 What’s in the box? Get with 1 or 2 neighbors: Try these now: (a) Convert 1212 3 to a base 10 number (b) Convert 45 to a base 2 number (c) Convert 45 to a base 4 number

17 COMP 4—Power Tools for the Mind 16 What’s in the box? (a) Convert 1212 3 to a base 10 number 3 4 3 3 3 2 3 1 3030 81 27 9 3 1 base place values powers 1 2 1 2323 1*27 + 2*9 + 1*3 + 2*1 =50 1212 3 = ? 10

18 (a) Convert 45 to a base 2 number 2 6 2 5 2 4 2 3 2 2 2 1 2 0 64 32 16 8 4 2 1 base place values powers 101101 45 10 = ? 2 --We KNOW the place values. --We are LOOKING for correct FACE values to plug in to the table! -- 1 st : What symbols can we use in this base? --2 nd : 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

19 (a) Convert 45 to a base 4 number 4 5 4 4 4 3 4 2 4 1 4 0 1024 256 64 16 4 1 base place values powers 45 10 = ? 4 231 --We KNOW the place values. --We are LOOKING for correct FACE values to plug in to the table! -- 1 st : What symbols can we use in this base? --2 nd : 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

20 COMP 4—Power Tools for the Mind 19 What’s in the box? To represent an integer value in some base x, how many correct answers are there? 13 10 = ? x for x ranging from 2 to infinity 13 10 = 1101 2 13 10 = 111 3 13 10 = 31 4 13 10 = 23 5 13 10 = 21 6 13 10 = 16 7 13 10 = 15 8 13 10 = 14 9 13 10 = 13 10 13 10 = 12 11 13 10 = 11 12 13 10 = 10 13 13 10 = D 14 13 10 = D 15 13 10 = D 16......

21 COMP 4—Power Tools for the Mind 20 What’s in the box? 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. Can also use a division algorithm to convert a decimal number to some base x number. example 44 10 = ? 2 44 / 2 = 22/ 2 = 11/ 2 = 5/ 2 = 2/ 2 = 1/ 2 = 0 001110 001110 quotient remainder

22 COMP 4—Power Tools for the Mind 21 What’s in the box? Base 10: DECImal numbering system Base 2: BInary numbering system Any base number can be converted to binary. But WHY BINARY? …. Voltage 0 1.0 0 1 Binary 0 1 2 3 4 5 6 7 8 9 Decimal

23 COMP 4—Power Tools for the Mind 22 What’s in the box? Logical structure, then: –Binary 0 s and 1 s: Bi nary digi ts. Bits. –Bit : smallest, most basic data unit in a computer. So how do we represent a bit “in the box”? 1 0 = Etc? 0000 = 0010 = 8 4 2 1 (place values) = 00010100 = = 0011 0 1 2 3 4

24 COMP 4—Power Tools for the Mind 23 What’s in the box? Binary numbers: general & powerful common representation for all these types: Numeric values Characters Visual Audio Instructional Encode as binary numbers (logical structure) 0 1 Appear as on/off signals at the hardware level (physical structure)

25 COMP 4—Power Tools for the Mind 24 What’s in the box? Numeric values in binary systems Whole numbers (pos & neg): we generally use a fixed # of bits. 32 bits allows for a positive value of >2 billion. #bits#possib’s 12 1 2 22 2 4 42 4 16 82 8 256 162 16 65536 322 32 4,294,967,296(~half positive)

26 COMP 4—Power Tools for the Mind 25 What’s in the box? –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.

27 COMP 4—Power Tools for the Mind 26 What’s in the box? Excess notation –sign = most significant bit –not generally used Negative numbers 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 5 10  000 101 2 –finding a negative number: take complement and add 1: - 5 10  - 000 101 2  111 010 2 + 000 001 2  111 011 2 number  15 bits1 bit number 16 bits 0000000000000101 5 -5 1000000000000101 0000000000000101 5 1111111111111011

28 COMP 4—Power Tools for the Mind 27 What’s in the box? Fixed point notation –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 2 3 2 2 2 1 2 0 2 -1 2 -2 2 -3 1011. 011=8 + 2 + 1 + 0.25 + 0.125 =11.375 Floating point notation  (1+m)  2 e me +127  23 bits8 bits1 bit 01000000101110000000000000000000= 5.75

29 COMP 4—Power Tools for the Mind 28 What’s in the box? Digression: Limitations on precision 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.

30 COMP 4—Power Tools for the Mind 29 What’s in the box? So what’s an important POINT here?

31 COMP 4—Power Tools for the Mind 30 What’s in the box? 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—similar to the way that complex transformations 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.


Download ppt "COMP 4—Power Tools for the Mind 1 What’s in the box? Representing concepts, Part 1 What we’ll cover for Part 1 : Representing concepts in a computer –Five."

Similar presentations


Ads by Google