Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science The Switch, Part One.

Similar presentations


Presentation on theme: "CSCI N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science The Switch, Part One."— Presentation transcript:

1 CSCI N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science The Switch, Part One

2 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Goals By the end of this unit, you should understand … Why computers use switches.Why computers use switches. Why computers encode everything using binary numbers.Why computers encode everything using binary numbers. How to convert to and from Base-2.How to convert to and from Base-2. How to convert to and from Base-8.How to convert to and from Base-8. How to convert to and from Base-16.How to convert to and from Base-16.

3 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Why do computers use switches? Engineers selected a binary-state (two state) switch as the fundamental computer component building block.Engineers selected a binary-state (two state) switch as the fundamental computer component building block. Why? It was simple and reliable and it supported built-in error checking.Why? It was simple and reliable and it supported built-in error checking.

4 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science The Switch and Architecture The innermost physical layer of a computer is a huge collection of simple, two state switches.The innermost physical layer of a computer is a huge collection of simple, two state switches. We can store any thing we want inside a computer, as long as we can figure out how to translate it into a collection of switches …We can store any thing we want inside a computer, as long as we can figure out how to translate it into a collection of switches …

5 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Switches and Meaning With one switch, how many messages can we convey? Two – I could let the open (“ON”) position represent the message “Yes, we’ll have class today.”, while the closed (“OFF”) position stands for “No, we will not.”With one switch, how many messages can we convey? Two – I could let the open (“ON”) position represent the message “Yes, we’ll have class today.”, while the closed (“OFF”) position stands for “No, we will not.” That’s not a lot of information, though, just two things …That’s not a lot of information, though, just two things …

6 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Putting Them Together What if I take two switches, put together?What if I take two switches, put together? Now, I have four things I can say:Now, I have four things I can say: –ON, ON: We’ll have class and a test. –ON, OFF: We’ll have class, but no test. –OFF, ON: We won’t have class, but we’ll have a test. –OFF, OFF: We won’t have class and we won’t have a test.

7 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Adding Switches Doubles Message 1 switch = 2 message1 switch = 2 message 2 switches = 4 messages2 switches = 4 messages 3 switches = 8 messages3 switches = 8 messages 4 switches = ? messages4 switches = ? messages Do you see a pattern?Do you see a pattern?

8 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Units of Computer Measurement The smallest unit of computer measurement is a binary digit (or more commonly, the “bit”).The smallest unit of computer measurement is a binary digit (or more commonly, the “bit”). The bit represents a single binary digit, either a 1 or a 0.The bit represents a single binary digit, either a 1 or a 0.

9 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Larger Units of Measurement Bit = A single binary digitBit = A single binary digit Nibble = 4 BitsNibble = 4 Bits Byte = 2 Nibbles = 8 BitsByte = 2 Nibbles = 8 Bits Word = 2 Bytes = 16 BitsWord = 2 Bytes = 16 Bits Double Word = 2 Words = 32 BitsDouble Word = 2 Words = 32 Bits Kilobyte = 1024 BytesKilobyte = 1024 Bytes Megabyte = 1024 KilobytesMegabyte = 1024 Kilobytes Gigabyte = 1025 MegabytesGigabyte = 1025 Megabytes

10 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Starting with Numbers Each switch can either have sufficient voltage (“ON”) or have insufficient voltage (“OFF”).Each switch can either have sufficient voltage (“ON”) or have insufficient voltage (“OFF”). Another way of stating voltage: 1 or 0Another way of stating voltage: 1 or 0 This is a common approach in science – to use abstract, notational systems to describe things.This is a common approach in science – to use abstract, notational systems to describe things. “1” “0”

11 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Numbering Systems To figure the answer to this question, let’s step back and look at numbering systems in general.To figure the answer to this question, let’s step back and look at numbering systems in general. Originally, human being counted with tally math systems, with a mark for each sheep they were countingOriginally, human being counted with tally math systems, with a mark for each sheep they were counting –If you had 10 sheep, you made 10 marks

12 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Numbering Systems Later, there were advancements in tally math, using special symbols for special numbers.Later, there were advancements in tally math, using special symbols for special numbers. –Instead of 10 marks for 10 sheep, let’s make a special mark for 10 sheep … –Instead of 10 marks for 10 sheep, let’s make a special mark for 10 sheep … But this notational system was cumbersome… you had to learn a lot of symbols, and arithmetic was difficultBut this notational system was cumbersome… you had to learn a lot of symbols, and arithmetic was difficult = = X X

13 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Positional Numbering Systems Wonderful advancement over tally math.Wonderful advancement over tally math. Let’s keep a few, core numbers (digits).Let’s keep a few, core numbers (digits). We can use these digits to represent REALLY big numbers if we say that the value of a number is now made up of 2 parts:We can use these digits to represent REALLY big numbers if we say that the value of a number is now made up of 2 parts: –A count value –A place value

14 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Place Values Consider the number 37…Consider the number 37… The 7 stands for 7 (it’s count value) ones (it’s positional value). Together, 7 times 1 is 7The 7 stands for 7 (it’s count value) ones (it’s positional value). Together, 7 times 1 is 7 3 7

15 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Place Values Consider the number 37…Consider the number 37… The 3 stands for 3 (it’s count value) tens (it’s positional value). Together, 3 times 10 is thirtyThe 3 stands for 3 (it’s count value) tens (it’s positional value). Together, 3 times 10 is thirty 3 7

16 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Place Values Consider the number 37…Consider the number 37… Total value: 7 (7 * 1, from the ones position) and thirty (3 * 10, from the 10 position) is 37!Total value: 7 (7 * 1, from the ones position) and thirty (3 * 10, from the 10 position) is 37! 3 73 7 3 73 7

17 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Place Values 3 73 7 3 73 7 “Ones” “Tens” 7 * 13 * 10

18 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Base-10 (Decimal) A base refers to the number of digits (counting numbers) available in a numbering scheme.A base refers to the number of digits (counting numbers) available in a numbering scheme. The highest single digit in base is one less than the base number.The highest single digit in base is one less than the base number. In Base-10, the digits are:In Base-10, the digits are: –0, 1, 2, 3, 4, 5, 6, 7, 8, 9

19 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Base-10 (Decimal) What happens after 9?What happens after 9? The counter in the right column resets itself to “0” and 1 is added to the value of the next left-most column:The counter in the right column resets itself to “0” and 1 is added to the value of the next left-most column: 0 90 90 90 9 1 0

20 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Base-10 (Decimal) Interpreting a multiple digit number simply means to expand its notation, and write it out by each positional value:Interpreting a multiple digit number simply means to expand its notation, and write it out by each positional value: 7 4 2 “Ones” 2 * 1 “Tens” 4 * 10 “Hundreds” 7 * 100

21 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Base-10 (Decimal) What about using some math to describe the number:What about using some math to describe the number: 7 4 2 10 0 2 * 10 0 4 * 10 1 7 * 10 2 10 1 10 2

22 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Using Expanded Notation We can use our expanded notation to figure the value of a number:We can use our expanded notation to figure the value of a number: 7*10 2 = 7*100 = 700 4*10 1 = 4*10 = 40 2*10 0 = 2*1 = 2 = 742 10

23 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science A Note on Superscripts We’ve seen superscripts in expressions before today. In math, they are used to indicate an exponent in an expression:We’ve seen superscripts in expressions before today. In math, they are used to indicate an exponent in an expression: xyxyxyxy

24 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science A Note on Subscripts Let’s introduce one more notation – the subscript. It is used to indicate the base of a number (the number of digits available in a numbering system):Let’s introduce one more notation – the subscript. It is used to indicate the base of a number (the number of digits available in a numbering system): xyxyxyxy

25 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science A Note on Subscripts Remember our previous example?Remember our previous example? It had a subscript of “10”, meaning that the number we use the Base-10 (Decimal) numbering system to decode this number.It had a subscript of “10”, meaning that the number we use the Base-10 (Decimal) numbering system to decode this number. 742 10

26 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Thinking in Binary (Base-2) Instead of having 10 digits, the binary (Base-2) numbering systems has 2 base digits (0 and 1).Instead of having 10 digits, the binary (Base-2) numbering systems has 2 base digits (0 and 1). –Counting in Base-2: 0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010 … In binary, after the right-most placeholder reaches one, it resets to 0 and advances the next left-most placeholder.In binary, after the right-most placeholder reaches one, it resets to 0 and advances the next left-most placeholder. Our base number in binary is 2, therefore we can use exponents of 2 for placeholder notationOur base number in binary is 2, therefore we can use exponents of 2 for placeholder notation

27 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Binary Placeholders 1 0 1 1 “Twos” “Ones” “Fours” “Eights” Let’s deconstruct 1011 2 :Let’s deconstruct 1011 2 :

28 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Binary Placeholders 1 0 1 1 2020 Now, let’s use exponents:Now, let’s use exponents: 21212 2323

29 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-2 to Base-10 Let’s convert 1011 2.Let’s convert 1011 2. STEP 1: Find all switches that are turned “OFF”. Cross them out and bring down the zero.STEP 1: Find all switches that are turned “OFF”. Cross them out and bring down the zero. 1 0 1 1 2020 21212 2323 0

30 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-2 to Base-10 STEP 2: For each placeholder turned “ON”, calculate its exponential expression.STEP 2: For each placeholder turned “ON”, calculate its exponential expression. 1 0 1 1 2020 21212 2323 0128

31 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-2 to Base-10 STEP 3: Add the results of the exponents. The sum is the Base-10 equivalent.STEP 3: Add the results of the exponents. The sum is the Base-10 equivalent. 1 0 1 1 2020 21212 2323 0128 +++ = 11 10

32 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting from Base-10 to Base-2 Consider 23 10. How can we translate this to its Base-2 equivalent?Consider 23 10. How can we translate this to its Base-2 equivalent? We’ll use successive division. Essentially, that means we’ll divide by 2 over and over and keep track of our remainders.We’ll use successive division. Essentially, that means we’ll divide by 2 over and over and keep track of our remainders. Let’s try it …Let’s try it …

33 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-10 to Base-2 STEP ONE: Draw a table with three columns. Label the last two columns quotient and remainder, respectively. QR

34 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-10 to Base-2 STEP TWO: In the first available left-most column, put the expression 23/2. Calculate the division and put the quotient and remainder in their respective columns. QR 23/2111

35 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-10 to Base-2 STEP THREE: Take the quotient of the previous expression and divide it by two. Repeat until have 0 for a quotient. QR 23/2111 11/251 5/221 2/210 1/201

36 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-10 to Base-2 STEP FOUR: Read the REMAINDER column from the bottom to the top. The 1s and 0s in the remainder column represent the binary number. QR 23/2111 11/251 5/221 2/210 1/201

37 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-10 to Base-2 23 10 = 10111 2 QR 23/2111 11/251 5/221 2/210 1/201

38 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Checking the Results So.. 23 10 = 10111 2!So.. 23 10 = 10111 2! Let’s check our answer by reversing the processLet’s check our answer by reversing the process 10111 2 = (1 * 2 4 ) + (0 * 2 3 ) + ( 1 * 2 2 ) + (1 * 2 1 ) + (1 * 2 0 ) =10111 2 = (1 * 2 4 ) + (0 * 2 3 ) + ( 1 * 2 2 ) + (1 * 2 1 ) + (1 * 2 0 ) = 16 + 0 + 4 + 2 + 1 = 23 1016 + 0 + 4 + 2 + 1 = 23 10

39 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Groups of Switches We have already seen that a single switch can’t encode much information. However, if we group switches together, we can expand our encoding ability.We have already seen that a single switch can’t encode much information. However, if we group switches together, we can expand our encoding ability. Computers often encode many types of data, graphics and large numbers for example, not in Base-2, but in Base-8 or Base-16.Computers often encode many types of data, graphics and large numbers for example, not in Base-2, but in Base-8 or Base-16.

40 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Introducing Octal Computer scientists are often looking for shortcuts to do things. One of the ways in which we can represent Base-2 numbers is to use their octal (Base-8) equivalents.Computer scientists are often looking for shortcuts to do things. One of the ways in which we can represent Base-2 numbers is to use their octal (Base-8) equivalents. This is especially helpful when we have to do fairly complicated tasks using large numbers.This is especially helpful when we have to do fairly complicated tasks using large numbers.

41 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Introducing Octal The octal numbering system includes eight base digits, 0-7.The octal numbering system includes eight base digits, 0-7. After 7, the next placeholder to the right begins with a 1: 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13...After 7, the next placeholder to the right begins with a 1: 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13...

42 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Octal Digits Base-2Base-8Base-10 00000 00111 01022 01133 10044 10155 11066 11177 Click to Return to the Last Slide Viewed

43 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Octal Placeholders “Ones” “Eights” “Sixty-Fours” 64*28*41*1 8 2 *2 8 1 *4 8 0 *1 241Number: Placeholder Name: Value: Exponential Expression:

44 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-2 to Base-8 STEP ONE: Take the binary number and from right to left, group all placeholders in triplets. Add leading zeros, if necessary: 10001100101001 2 010001101 100 001 Click to See Octal Digits Table

45 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-2 to Base-8 STEP TWO: Convert each triplet to its single-digit octal equivalent. (HINT: For each triplet, the octal conversion is the same as converting to a decimal number): 10001100101001 2 010001101 100 001 21154 21451 8 =

46 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-8 to Base-2 Take each octal digit and convert each digit to a binary triplet. Insert leading zeros, if needed: 43520 8 100000010 101 011 43025 100011101010000 2 = Click to See Octal Digits Table

47 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-8 to Base-10 Multiply each octal digit by the exponential expression that represents its placeholder and then add the values: 2374 8 = N 10 2*8 3 = 2*512 = 1024 2*8 3 = 2*512 = 1024 8 3*8 2 = 3*64 = 192 3*8 2 = 3*64 = 192 8 7*8 1 = 7*8 = 56 7*8 1 = 7*8 = 56 8 4*8 0 = 4*1 = 4 4*8 0 = 4*1 = 4 8 = 1276 10

48 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-10 to Base-8 To convert Base-10 to Base-8, we’ll use successive division … Our new problem: 4832 10 = ? 8

49 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-10 to Base-8 STEP ONE: Draw a table with three columns. Label the last two columns quotient and remainder, respectively. QR

50 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-10 to Base-8 STEP TWO: In the first available left-most column, put the expression 4832/8. Calculate the division and put the quotient and remainder in their respective columns. QR 4832/86040

51 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-10 to Base-8 STEP THREE: Take the quotient of the previous expression and divide it by eight. Repeat until you’ve have 0 for a quotient. QR 4832/86040604/8754 75/893 9/811 1/801

52 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-10 to Base-8 STEP FOUR: Read the REMAINDER column from the bottom to the top. The numbers in the remainder column represent the octal number. QR 4832/86040 604/8754 75/893 9/811 1/801

53 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-10 to Base-8 4832 10 = 11340 8 QR 4832/86040 604/8754 75/893 9/811 1/801

54 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Base-16 What’s tricky about Base-16?What’s tricky about Base-16? This time, we are converting to a base that has more base digits than Base-10 (Base-2 and Base-8 have fewer digits than Base-10)This time, we are converting to a base that has more base digits than Base-10 (Base-2 and Base-8 have fewer digits than Base-10) So what?So what?

55 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Hexadecimal Numbering There are new symbols for the Base-16 equivalents of the Base-10 numbers 10, 11, 12, 14 and 15. Examine:There are new symbols for the Base-16 equivalents of the Base-10 numbers 10, 11, 12, 14 and 15. Examine: DEC01234567 HEX01234567 DEC89101112131415 HEX89ABCDEF

56 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-10 to Base-16 To convert Base-10 to Base-16, we’ll again use successive division … Our new problem: 214 10 = ? 16

57 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-10 to Base-16 STEP ONE: Draw a table with three columns. Label the last two columns quotient and remainder, respectively. QR

58 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-10 to Base-16 STEP TWO: In the first column, write the expression 214/16. Calculate the expression, taking care not to divide past the decimal point. Write the quotient and remainder in their respective columns. QR 214/16136

59 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-10 to Base-16 STEP THREE: Keep bringing down the quotient of the previous expression and dividing it by 16 until you have a quotient of zero. QR 214/16136 13/16013

60 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-10 to Base-16 STEP FOUR: Convert all remainders to their hex equivalents. QR 214/1613 6 = 6 13/160 13 = D

61 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Converting Base-10 to Base-16 STEP FIVE: Read the numbers in the REMAINDER column from the bottom up to get your hex equivalent. QR 214/1613 6 = 6 13/160 13 = D 214 10 = D6 16

62 N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science Questions?


Download ppt "CSCI N301: Fundamental Computer Science Concepts Copyright ©2006  Department of Computer & Information Science The Switch, Part One."

Similar presentations


Ads by Google