Unformatted text preview:

Representing Concepts Part 2--Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12So, to get more things represented, we just keep adding bits (or light bulbs)Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24Slide 25Slide 26Slide 27Slide 28Slide 29Slide 30Slide 31Slide 32Slide 33Slide 34Slide 35Slide 36Slide 37Slide 38Slide 39COMP 4—Power Tools for the Mind1What’s in the box?Representing Concepts Part 2--What we’ll cover for Part 2 :•Representing concepts in a computer–1st type: Numeric values --brief review–Today: How are some of the other concepts represented in the box?1234COMP 4—Power Tools for the Mind2What’s in the box?Information theory: Study of the most efficient way to encode concepts: information that interests us.–All information must be captured & stored, processed, and transmitted.–Using numbers to represent information allows us to use a discrete symbol system: distinct, unambiguous, precise.–Discrete numbers are much easier to engineer than continuous numbers.Quick review of Part 1:•How do we represent numeric values such as 1378 or 17.2351 in a computer?–Logical structure? Physical structure?–Mathematical operations (add, subtract, multiply, divide) operate on numeric information.COMP 4—Power Tools for the Mind3What’s in the box?Digression: Binary AdditionSum: 1 0 1 1 base 2 1 1 1 1 base 201Carry:110111Rules• 0 + 0 = 0• 1 + 0 = 0 + 1 = 1• 1 + 1 = 1 0COMP 4—Power Tools for the Mind4What’s in the box?Representing characterscharacters•With unique bit patterns, we can represent any character (including foreign characters), just the way we already used unique bit patterns to represent decimal values……–Digression: the program determines if a stored bit pattern represents a numeric value, or an alphanumeric text, or part of a sound, or part of a picture, or part of an instruction.....•A - Z a - z 0 - 9 ! @ # $ % ^ & * ( ) + =•Must work with binary coding schemes (why?)COMP 4—Power Tools for the Mind5What’s in the box?•However: Bit patterns that represent characters (alphanumeric) are typically not used used for mathematical computations like add or subtract.•Instead: alphanumeric characters are mostly used to store textual content, which may be sorted or concatenated.•So: although both numeric values (used for counting & math) and alphanumeric characters (used for text) are both represented using a bit pattern, they are treated differently.Another digression:COMP 4—Power Tools for the Mind6What’s in the box?–Number characters (alphanumeric) are treated by the computer as text characters: • 9 not= “9” • 9 + 9 = 18 while “9” + “9” = “99” The Binary pattern that represents 9 is different from the binary pattern that represents “9”.–yet sorting is possible because text characters also have a binary (numeric) value:The numeric value of the binary representation of a is smaller than b and also b is smaller than c and so on …Consider:COMP 4—Power Tools for the Mind7What’s in the box? Letter BB in binary code Letter BB“in the box” 128 64 32 16 8 4 2 1 “Place”“0” 0 1 0 1 0 0 0 0“1” 0 1 0 1 0 0 0 1“2” 0 1 0 1 0 0 1 0“A” 0 1 0 0 0 0 0 1“B” 0 1 0 0 0 0 1 0How to represent C C ???NOTICE how A < B < C ……“C” 0 1 0 0 0 0 1 1COMP 4—Power Tools for the Mind8What’s in the box?Number of symbols possibleRemember?x bits could represent 2x numbers2 bits  22 = 4 different bit patterns4 bits?  16 different [24 = 16]Bit pattern 0000000100100011010001010110011110001001101010111100110111101111Decimal value 0 1 2 3 4 5 6 7 8 9101112131415SAME THING when representingalphanumeric characters:A two-bit code (two bulbs) can represent(e.g. encode) four unique characters.COMP 4—Power Tools for the Mind9What’s in the box?0 0=AB0 1=C1 0=D1 1= 22 = 4Base # bits = number of unique combinations (that represent values)COMP 4—Power Tools for the Mind10What’s in the box?Base# of bits used = number of unique symbols the coding scheme can representBit pattern lengthLOGICAL Representation (bit coding scheme):#-of-States # of bulbs = number of unique symbols the bulbs can representHow many bulbs (switches, transistors, vacuum tubes, magnetized locations on disk, ...)PHYSICAL Representation (hardware “bits”):CORRESPONDS DIRECTLY to theCOMP 4—Power Tools for the Mind11What’s in the box?What if we use more expensive light bulbs? OFF LOW HIGH#-of-States # of bulbs = number of unique combinations; which indicates number of unique values the bulbs can represent QUICK! Would that allow us to represent/encode MORE or LESS unique things? WHY? (assume will use only 2 bulbs)0 0=ABCD0 10 21 0===1 1=EFGH1 22 02 1===2 2=IThen what has changed? Not how many bulbs, but what? 32 = 9 combinationsCOMP 4—Power Tools for the Mind12What’s in the box?What if we don’t want to use complicated bulbs---how else can we INCREASE how many things can be represented??So, base (# of states) is two: (0 , 1) (off , on) NOW what MUST change? =H?1 111 100 0=A00 0=B10 10=C0 1=D11 0=E01 01=F=G23 = 8 combinationsBase# of bits used = number of unique things the coding scheme can represent#-of-States # of bulbs = number of unique combinations; which indicates number of unique things the bulbs can representCOMP 4—Power Tools for the Mind13What’s in the box?So, to get more things represented, we just keep adding bits (or light bulbs)22 = 4 combinations23 = 8 “24 = 16 “25 = 32 “26 = 64 “27 = 128 “28 = 256 “ 216= 65536 “ .... ....COMP 4—Power Tools for the Mind14What’s in the box?For alphanumeric character values:Bit pattern0101 0000 0101 00010101 00100101 0011(etc)0100 00010100 00100100 00110100 01000100 0101(etc)Character (text) value 0 1 2 3(etc) A B C D E(etc)7, 8, 16, 32, and 64-bit patterns are used for alphanumeric character values:27= 128 character values28= 256 character values216= 65,536 character values232= > 4 billion char values264= 18,446,744,073,709,551,616 character values14COMP 4—Power Tools for the Mind15What’s in the box?Challenge 1: 26 upper-case characters in our


View Full Document

UNC-Chapel Hill COMP 004 - LECTURE NOTES

Download LECTURE NOTES
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view LECTURE NOTES and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view LECTURE NOTES 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?