Presentation is loading. Please wait.

Presentation is loading. Please wait.

ICS124 Session 2 Data Representation 1. Review QUIZ 1) Additional data and programs not being used by the processor are stored in: a) secondary storagec)

Similar presentations


Presentation on theme: "ICS124 Session 2 Data Representation 1. Review QUIZ 1) Additional data and programs not being used by the processor are stored in: a) secondary storagec)"— Presentation transcript:

1 ICS124 Session 2 Data Representation 1

2 Review QUIZ 1) Additional data and programs not being used by the processor are stored in: a) secondary storagec) input units b) output unitsd) the CPU 2) The entire computer system is coordinated by: a) the ALUc) registers b) the control unitd) arithmetic operators 3) The control unit operates in: a) E-timec) machine time b) I-timed) ALU time 4) "Mark sensing" is another term for: a) MICRc) OMR b) POSd) OCR 5) Another name for secondary storage is: a) cylinder storagec) auxiliary storage b) densityd) memory 2

3 Review QUIZ 1) Additional data and programs not being used by the processor are stored in: a) secondary storagec) input units b) output unitsd) the CPU 2) The entire computer system is coordinated by: a) the ALUc) registers b) the control unitd) arithmetic operators 3) The control unit operates in: a) E-timec) machine time b) I-timed) ALU time 4) "Mark sensing" is another term for: a) MICRc) OMR b) POSd) OCR 5) Another name for secondary storage is: a) cylinder storagec) auxiliary storage b) densityd) memory 3

4 Objectives: By the end of this session, the student will be able to:  Define a Positionally Dependent numbering system  Give examples of positionally dependent and positionally independent numbering systems  List the digits used in the binary, octal and hexadecimal numbering system  Express each position of significance as the base to an appropriate exponent  List the steps to convert a decimal number to any numbering system  Use the technique to perform conversions of decimal numbers to binary, octal and hexadecimal numbering systems  Explain the process of converting from any numbering system to the decimal number system  Use the process to perform conversions of binary, octal or hexadecimal numbering systems to the decimal numbering system  List the steps of the short-cut to convert a binary number to an octal number  Use the technique to perform binary to octal conversions  List the steps of the short-cut to convert a binary number to a hexadecimal number  Use the technique to perform binary to hexadecimal conversions  List the steps of the short-cut to convert an octal number to a binary number  Use the technique to perform octal to binary conversions  List the steps of the short-cut to convert a hexadecimal number to a binary number  Use the technique to perform hexadecimal to binary conversions  Define the terms: bits, bytes, nibbles and words  Explain why computers use the binary numbering system 4

5 Numbering Systems Background Numbering systems have been around since the concept of quantity was developed. With the advent of writing, numbering systems have been recorded starting with the Babylonian numbering system around 3100BC: http://www.phys.virginia.edu/classes/109N/lectures/babylon.html1996 Michael Fowler 5

6 Numbering Systems, Continued Background, continued The Roman numbering system is still used today, but not as a functional system. The numbering system widely used today is the Arabic numbering system: ArabicRoman 1I 2II 3III 4IV 5V 6VI 7VII 8VIII 9IX 10X 50L 100C 500D 1000M 6

7 Numbering Systems, Continued Decimal numbering system The Arabic numbering system is a Decimal numbering system. There are three attributes we will look at:  The digits of this numbering system are positionally dependent.  It is based on a quantity of 10.  Contains the digits: 0 1 2 3 4 5 6 7 8 9 Positionally dependent Positionally dependent means that the significance of a digit is related to where it can be found in the number. For example, does the digit '1' mean the same thing in these two numbers? 51 163 These are the same numbers in Roman numerals, does the different position of the 'L' character change its significance? LI CLXIII 7

8 Numbering Systems, Continued Positionally dependent, continued A closer look at the composition of a decimal number: 1492 Is composed of 1000 + 400 + 90 + 2. Another way of expressing this is: 1492 = (1 x 1000) + (4 x 100) + (9 x 10) + (2 x 1) If we take the multipliers (1000, 100, 10, 1) and express them as exponents of the base: 1000 = 10 3 (10 x 10 x 10 - ten multiplied by itself 3 times) 100 = 10 x 10 = 10 2 (10 x 10 - ten multiplied by itself 2 times) 10 = 10 1 1 = 10 0 1492 = (1 x 10 3 ) + (4 x 10 2 ) + (9 x 10 1 ) + (2 x 10 0 ) 8

9 Numbering Systems, Continued Positionally dependent, continued In summary, we can say that a digit's significance is dependent on its position within the number. The more digits that sit to a digits right, the more significant the digit: 88888 In the above number the '8' that is the rightmost digit has less significance than the '8' digit that is leftmost. Terms such as  'Least Significant Digit' (LSD), and  'Most Significant Digit' (MSD) are used to describe this property. As more significant digits are added, the exponent is increased by one.... 10 6 10 5 10 4 10 3 10 2 10 1 10 0 9

10 Numbering Systems, Continued Based on 10 The base of the exponents gives the numbering system its name. So the decimal numbering system is also referred to as base-10. The digits of the decimal numbering system cycle on every tenth digit. Once all of the digits have been exhausted, the next highest position of significance is updated by one. Starting at zero, to exhaust all possible digits, the order would be: 0 1 2 3 4 5 6 7 8 9 10

11 Numbering Systems, Continued Based on 10, continued To increment by 1, the next highest position of significance is updated, and the cycle repeats: 010 111 212 313 414 515 616 717 818 919 11

12 Numbering Systems, Continued Based on 10, continued By convention, the '0' that became a '1' in the left column is not written, otherwise we would see: 0010 0111 0212 0313 0414 0515 0616 0717 0818 0919 As there are an infinite number of positions of significance, it is actually impossible to write all the leading zeroes for numbers. 12

13 Numbering Systems, Continued Based on 10, continued A list of decimal numbers (leading zeroes added): 000017034051068085102119136153 001018035052069086103120137154 002019036053070087104121138155 003020037054071088105122139156 004021038055072089106123140157 005022039056073090107124141158 006023040057074091108125142159 007024041058075092109126143160 008025042059076093110127144161 009026043060077094111128145162 010027044061078095112129146163 011028045062079096113130147164 012029046063080097114131148165 013030047064081098115132149166 014031048065082099116133150167 015032049066083100117134151168 016033050067084101118135152.... 13

14 Numbering Systems, Continued General statements Some general statements about positionally dependent numbering systems, using the Base-10 numbering system as an example:  There are base digits in the system (base is 10, therefore there are 10 digits)  The digits in the numbering system start at 0 and go to base - 1 (base is 10, therefore base - 1 is 9. Therefore, the digits go from 0 to 9)  The digits of significance, starting at the right, and moving left are:  expressed as an exponent where the base is the base of the numbering system- which is how the term 'base' comes to be  the exponents start at 0 and increment by 1 for each digit of significance 14

15 Numbering Systems, Continued General statements Some general statements about positionally dependent numbering systems:  There are base digits in the system  The digits in the numbering system start at 0 and go to base - 1  The digits of significance, starting at the right, and moving left are:  expressed as an exponent where the base is the base of the numbering system- which is how the term 'base' comes to be  the exponents start at 0 and increment by 1 for each digit of significance What would the binary (base-2) numbering system look like? 15

16 Numbering Systems, Continued Binary numbering system The binary numbering system has three attributes that we will look at:  The digits of this numbering system are positionally dependent.  It is based on a quantity of 2.  Contains the digits: 0 1 Positionally dependent The definition remains the same as in the decimal numbering system. However, lets take a closer look at the composition of a binary number. 1101(this number is not one thousand one hundred and one) Looking back at the base-10 numbering system, as more significant digits were added, the exponent of the base increased by one. Using this a model, then the significance of the digits within the binary numbering system would be:... 2 6 2 5 2 4 2 3 2 2 2 1 2 0 16

17 Numbering Systems, Continued Positionally dependent, continued The number 1101 could be expressed as: (1 x 2 3 ) + (1 x 2 2 ) + (0 x 2 1 ) + (1 x 2 0 ) There are differences when referring to binary digits, they are called bits. Also, the terms for significance are:  Least Significant Bit (LSB), and  Most Significant Bit (MSB) 17

18 Numbering Systems, Continued Based on 2 The base of the exponents gives the numbering system its name. So the binary numbering system is also referred to as base-2. The digits of the binary numbering system cycle on every second bit. Once all of the bits have been exhausted, the next highest position of significance is updated by one. Starting at zero, to exhaust all possible bits, the order would be: 0 1 A list of binary numbers (leading zeroes added): 00000010001000011000 00001010011000111001 00010010101001011010 00011010111001111011 00100011001010011100 00101011011010111101 00110011101011011110 00111011111011111111.... 18

19 Numbering Systems, Continued General statements Some general statements about positionally dependent numbering systems:  There are base digits in the system  The digits in the numbering system start at 0 and go to base - 1  The digits of significance, starting at the right, and moving left are:  expressed as an exponent where the base is the base of the numbering system- which is how the term 'base' comes to be  the exponents start at 0 and increment by 1 for each digit of significance What would the octal (base-8) numbering system look like? 19

20 Numbering Systems, Continued Octal numbering system The octal numbering system has three attributes that we will look at:  The digits of this numbering system are positionally dependent.  It is based on a quantity of 8.  Contains the digits: 0 1 2 3 4 5 6 7 Positionally dependent The definition remains the same as in the decimal numbering system. However, lets take a closer look at the composition of an octal number. 571 Looking back at the base-10 numbering system, as more significant digits were added, the exponent of the base increased by one. Using this a model, then the significance of the digits within the octal numbering system would be:... 8 6 8 5 8 4 8 3 8 2 8 1 8 0 20

21 Numbering Systems, Continued Positionally dependent, continued The number 571 could be expressed as: (5 x 8 2 ) + (7 x 8 1 ) + (1 x 8 0 ) 21

22 Numbering Systems, Continued Based on 8 The base of the exponents gives the numbering system its name. So the octal numbering system is also referred to as base-8. The digits of the octal numbering system cycle on every eighth digit. Once all of the digits have been exhausted, the next highest position of significance is updated by one. Starting at zero, to exhaust all possible digits, the order would be: 0 1 2 3 4 5 6 7 22

23 Numbering Systems, Continued Based on 8, continued A list of octal numbers (leading zeroes added): 000021 001022 002023 003024 004025 005026 006027 007030 010031 011032 012033 013034 014035 015036 016037 017040 020041.... 23

24 Numbering Systems, Continued Octal Add 1 to each of the octal numbers below: 1 + 1 = 27 + 1 = 23 + 1 = 177 + 1 = 16 + 1 = 77 + 1 = 24

25 Numbering Systems, Continued Octal, continued Add 1 to each of the octal numbers below: 1 + 1 = 2 27 + 1 = 30 23 + 1 = 24 177 + 1 = 200 16 + 1 = 17 77 + 1 = 100 25

26 Numbering Systems, Continued General statements Some general statements about positionally dependent numbering systems:  There are base digits in the system  The digits in the numbering system start at 0 and go to base - 1  The digits of significance, starting at the right, and moving left are:  expressed as an exponent where the base is the base of the numbering system- which is how the term 'base' comes to be  the exponents start at 0 and increment by 1 for each digit of significance What would the hexadecimal (base-16) numbering system look like? 26

27 Numbering Systems, Continued Hexadecimal numbering system The hexadecimal numbering system has three attributes that we will look at:  The digits of this numbering system are positionally dependent.  It is based on a quantity of 16.  Contains the digits: 0 1 2 3 4 5 6 7 8 9 A B C D E F Positionally dependent The definition remains the same as in the decimal numbering system. However, lets take a closer look at the composition of a hexadecimal number. 1492 Looking back at the base-10 numbering system, as more significant digits were added, the exponent of the base increased by one. Using this a model, then the significance of the digits within the hexadecimal numbering system would be:... 16 6 16 5 16 4 16 3 16 2 16 1 16 0 27

28 Numbering Systems, Continued Positionally dependent, continued The number 1492 could be expressed as: (1 x 16 3 ) + (4 x 16 2 ) + (9 x 16 1 ) + (2 x 16 0 ) 28

29 Numbering Systems, Continued Based on 16 The base of the exponents gives the numbering system its name. So the hexadecimal numbering system is also referred to as base-16. The digits of the hexadecimal numbering system cycle on every sixteenth digit. Once all of the digits have been exhausted, the next highest position of significance is updated by one. The three numbering systems we have looked at use the Arabic numerals to represent the digits. The hexadecimal numbering system has more digits than can be accommodated using the Arabic symbols. The solution is to use alphabetic letters to represent the digits beyond 9. 29

30 Numbering Systems, Continued Based on 16, continued Starting at zero, to exhaust all possible digits, the order would be: 0 1 2 3 4 5 6 7 8 9 A B C D E F 30

31 Numbering Systems, Continued Based on 16, continued A list of hexadecimal numbers (leading zeroes added): 000010 001011 002012 003013 004014 005015 006016 007017 008018 009019 00A01A 00B01B 00C01C 00D01D 00E01E 00F01F.... 31

32 Numbering Systems, Continued Hexadecimal Add 1 to each of the hexadecimal numbers below: 1 + 1 = 9 + 1 = E + 1 = 45 + 1 = F + 1 = C5B + 1 = 1F + 1 = 2FF + 1 = 32

33 Numbering Systems, Continued Hexadecimal Add 1 to each of the hexadecimal numbers below: 1 + 1 = 2 9 + 1 = A E + 1 = F 45 + 1 = 46 F + 1 = 10 C5B + 1 = C5C 1F + 1 = 20 2FF + 1 = 300 33

34 Converting between bases 34

35 Converting between bases Converting between numbering systems Most people are comfortable dealing with a specific numbering system, such as decimal. To work with numbers in another numbering system, such as hexadecimal, it is often preferable to convert the hexadecimal number to decimal in order to perform the work (for example, multiplying two hexadecimal numbers together). In some cases conversions between binary and octal or hexadecimal is required. It is inconvenient to convert first to decimal, then to the new base, so some short cuts exist. 35

36 Converting between bases, continued Writing convention What is the value of the following number? 10 36

37 Converting between bases, continued Writing convention What is the value of the following number? 10 is it (1 x 2 1 ) + (0 x 2 0 ) or (1 x 10 1 ) + (0 x 10 0 ) or (1 x 8 1 ) + (0x8 0 ) or (1 x 16 1 ) + (0 x 16 0 ) 37

38 Converting between bases, continued Writing convention, continued To prevent confusion, the base of the number is subscripted after the number, so we know that 10 16 is 10 10 is 10 8 is 10 2 is 38

39 Converting between bases, continued Converting between bases Here are the first 20 10 numbers of each of the 4 numbering systems discussed: DecimalBinaryOctalHexadecimal 0000 1111 21022 31133 410044 510155 611066 711177 81000108 91001119 10101012A 11101113B 12110014C 13110115D 14111016E 15111117F 16100002010 17100012111 18100102212 19100112313 39

40 Converting between bases, continued Converting between bases You could create a table of the four numbering systems from 0 to infinity to perform conversions, or you could learn some basic techniques that can be applied to perform the conversions. 40

41 Converting between bases, continued Whole Number Division Remember the terminology used in whole number division: a / b = c R d a is called the dividend b is called the divisor c is called the quotient d is called the remainder e.g. 7 / 2 = 3 R 1 7 is the dividend 2 is the divisor 3 is the quotient 1 is the remainder 41

42 Converting between bases, continued Converting from decimal The process is the same for any base when converting from decimal. The digits created will begin at the least significant digit and work its way to the left (to the most significant digit). 1)divide the decimal number by the base, getting quotient and remainder 2)the remainder is the digit in the new numbering system (written to the left of the previous number) 3)take the quotient as a decimal number and repeat from step 1, until the quotient is 0 42

43 Converting between bases, continued Converting from decimal, continued Convert 1492 10 to base 10 (this will show the process): 1492 / 10 = 149 R2 149 / 10 = 14 R9 14 / 10 = 1 R 4 1 / 10 = 0 R 1 1492 10 43

44 Converting between bases, continued Converting from decimal, continued Convert 13 10 to base 2: ?? 44

45 Converting between bases, continued Converting from decimal, continued Convert 13 10 to base 2: 13 / 2 = 6 R 1 6 / 2 = 3 R 0 3 / 2 = 1 R 1 1 / 2 = 0 R 1 13 10 = 1101 2 45

46 Converting between bases, continued Converting from decimal, continued Convert 1084 10 to base 16: Remember that hexadecimal has alphabetic letters to represent values between 10 10 and 15 10 : A 16 = 10 10 B 16 = 11 10 C 16 = 12 10 D 16 = 13 10 E 16 = 14 10 F 16 = 15 10 1084 / 16 = 67 R 12 (12 10 = C 16 ) 67 / 16 = 4 R 3 4 / 16 = 0 R 4 1084 10 = 43C 16 46

47 Converting between bases, continued Converting from decimal, continued Convert 167 10 to base 8: ? 47

48 Converting between bases, continued Converting from decimal, continued Convert 167 10 to base 8: 167 / 8 = 20 R 7 20 / 8 = 2 R 4 2 / 8 = 0 R 2 167 10 = 247 8 48

49 Converting between bases, continued Converting from decimal, continued Perform the following conversions: Base-10Base-2Base-8Base-16 155 3434 473 2562 190 2989 49

50 Converting between bases, continued Converting from decimal, continued Perform the following conversions: Base-10Base-2Base-8Base-16 155100110112339B 34341101011010106552D6A 4731110110017311D9 25621010000000105002A02 19010111110276BE 29891011101011015655BAD 50

51 Converting between bases, continued Converting to decimal The process is the same for any base when converting to decimal, and is easier than converting from decimal to a base. If 'b' is the base (ie. 2, 8, 16), 'd' is the digit, and 'e' is the exponent of the base, then the formula: n  d e b e e=0 will perform the conversion. This means: d n b n +... + d 3 b 3 + d 2 b 2 + d 1 b 1 + d 0 b 0 51

52 Converting between bases, continued Converting to decimal, continued n  d e b e ==> d n b n +... + d 3 b 3 + d 2 b 2 + d 1 b 1 + d 0 b 0 e=0 Assuming base-2, and the bits: 1011011 2, then 1x2 6 + 0x2 5 + 1x2 4 + 1x2 3 + 0x2 2 + 1x2 1 + 1x2 0 = (1 x 64) + (0 x 32) + (1 x 16) + (1 x 8) + (0 x 4) + (1 x 2) + (1 x 1) = 64 + 16 + 8 + 2 + 1 = 91 10 52

53 Converting between bases, continued Converting to decimal, continued n  d e b e ==> d n b n +... + d 3 b 3 + d 2 b 2 + d 1 b 1 + d 0 b 0 e=0 Assuming base-16, and the digits: C0FFEE 16, then Cx16 5 + 0x16 4 + Fx16 3 + Fx16 2 + Ex16 1 + Ex16 0 = (12 x 1,048,576) + (0 x 65,536) + (15 x 4,096) + (15 x 256) + (14 x 16) + (14 x 1) = 12,582,912 + 0 + 61,440 + 3,840 + 224 + 14 = 12,648,430 10 53

54 Converting between bases, continued Converting to decimal, continued n  d e b e ==> d n b n +... + d 3 b 3 + d 2 b 2 + d 1 b 1 + d 0 b 0 e=0 Assuming base-8, and the digits: 654 8, then ? 54

55 Converting between bases, continued Converting to decimal, continued n  d e b e ==> d n b n +... + d 3 b 3 + d 2 b 2 + d 1 b 1 + d 0 b 0 e=0 Assuming base-8, and the digits: 654 8, then 6x8 2 + 5x8 1 + 4x8 0 = (6 x 64) + (5 x 8) + (4 x 1) = 384 + 40 + 4 = 428 10 55

56 Converting between bases, continued Converting to decimal, continued Convert the following to decimal: DEED 16 321 8 10010110 2 56

57 Converting between bases, continued Converting to decimal, continued Convert the following to decimal: DEED 16 = 57069 10 321 8 = 209 10 10010110 2 = 150 10 57

58 Converting between bases, continued Converting from binary There are many occurrences when you will convert from binary to a base other than 10, or vice versa. There are short-cuts for these conversions. Binary to octal To convert from binary to octal: 1)Start at the least significant bit, and place the bits into groups of three bits 2)Convert each of these groups (independent of each other) into octal digits For example, convert 1010011111 2 to octal: 1-010-011-111 = 1237 8 58

59 Converting between bases, continued Binary to hexadecimal To convert from binary to hexadecimal: 1)Start at the least significant bit, and place the bits into groups of four bits 2)Convert each of these groups (independent of each other) into hexadecimal digits For example, convert 1010011111 2 to hexadecimal: 10-1001-1111 = 29F 16 59

60 Converting between bases, continued Octal to binary To convert from octal to binary, the reverse process is applied. Convert each octal digit into groups of three bits: For example, convert 3215 8 to binary: 011-010-001-101 = 11010001101 2 60

61 Converting between bases, continued Hexadecimal to binary To convert from hexadecimal to binary, the reverse process is applied. Convert each hexadecimal digit into groups of four bits: For example, convert 10AD 16 to binary: 0001-0000-1010-1101 = 1000010101101 2 61

62 Converting between bases, continued Practice Convert the following numbers to the requested base. Use the shortcuts from the lecture: FEED 16 to base-2 1010111011001011011 2 to base-16 111101101100011 2 to base-8 D0CA 16 to base-8 62

63 Converting between bases, continued Practice Convert the following numbers to the requested base. Apply shortcuts if appropriate: FEED 16 to base-2 = 1111111011101101 2 1010111011001011011 2 to base-16 = 5765B 16 111101101100011 2 to base-8 = 75543 8 D0CA 16 to base-8 = 1101000011001010 2 = 150312 8 63

64 Converting between bases, continued Summary The following chart summarizes the techniques to use based on the conversion desired: 64

65 Binary and computers 65

66 Binary and computers Why computers use binary The previous slides regarding various numbering systems have relevance to computers. What is it about a numbering system with two digits that makes it ideal for computers? An electrical switch can have two states, either is on, or its off. A computer, being electrical, uses electrical switches to store data. 66

67 Binary and computers Why computers use binary, continued A switch that is turned on can represent the bit '1', and a switch that is turned off can represent the bit '0'. OFFONONOFFON 01101 RAM and ROM memory are massive arrays of these switches. A 32MB RAM chip would contain over 268 million of these switches. 67

68 Binary and computers, continued Bits, Bytes, Nibbles and Words We have defined a bit as a single binary digit, that is either a '0' or a '1'. There are other terms used when dealing with binary numbers that is based on the number of bits in the number. These terms are:  Bytes  Nibbles  Words Bytes In computers we look at bits in groups of eight. Early computers could not hold binary number that contained more than eight digits (bits). A group of eight bits is referred to as a byte. Remember the aggregate terms for memory? KB, MB and GB? The 'B' represented bytes (8 bits). Sometimes you will see Kb or Mb. This is an aggregate of bits. Be wary of this and perform conversions as required. That is why on the previous slide I said 32MB RAM would contain over 268 million bits (switches). 68

69 Binary and computers, continued Nibbles When performing conversions to hexadecimal, the bits are grouped four at a time. So when we talk about groups of 4 bits we refer to a nibble. Words Words are not a fixed size relative to bits. A word is related to the processor in the computer system. Inside the CPU, there are registers under the direction of the Control Unit. The number of bits that make up these registers defines the word size of a CPU. Another register that define word size is the ALU. CPUNumeric rangeProcessor 8-bit0 - 2558088 / 8086 16-bit0 - 65,53580286 32-bit0 - 4,294,967,295i386...Pentium4 64-bit0 - 1.844674407x10 19 Itanium, Sparc (Sun), Power3-II (IBM) 69

70 Binary and computers, continued Summary of terms What we have is: 1 bit 4 bits = 1 nibble 8 bits = 2 nibbles = 1 byte 70

71 Binary and computers, continued Role of Octal and Hexadecimal The octal and hexadecimal systems are used in computer systems to work with bits in more manageable chunks. Instead of looking a string of bits such as 010101110110 2, and 010101100110 2, it is easier to work with 576 16 and 566 16 or 2566 8 and 2546 8. Octal is used far less than hexadecimal, however, in UNIX being able to work with octal numbers is necessary when setting up file permissions. 71


Download ppt "ICS124 Session 2 Data Representation 1. Review QUIZ 1) Additional data and programs not being used by the processor are stored in: a) secondary storagec)"

Similar presentations


Ads by Google