ECE2030 Introduction to Computer Engineering Lecture 2 Number System Prof Hsien Hsin Sean Lee School of Electrical and Computer Engineering Georgia Tech Decimal Number Representation Example 90134 base 10 used by Homo Sapien 90000 0 100 30 4 9 104 0 103 1 102 3 101 4 100 How did we get it 10 90134 10 9013 10 901 10 90 9 4 3 1 0 2 Generic Number Representation 90134 9 104 0 103 1 102 3 101 4 100 A4 A3 A2 A1 A0 for base 10 or radix 10 A4 104 A3 103 A2 102 A1 101 A0 100 A is coefficient b is base Generalize for a given number N w base b N An 1 An 2 A1 A0 N An 1 bn 1 An 2 bn 2 A2 b2 A0 b0 Note that A b 3 Counting numbers with base b 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 90 21 91 22 92 23 93 24 94 25 95 26 96 27 97 28 98 29 99 Base 10 100 101 102 103 104 105 106 107 108 109 0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 20 70 21 71 22 72 23 73 24 74 25 75 26 76 27 77 100 101 102 103 104 105 106 107 How about Base 8 4 How about base 2 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 5 How about base 2 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 6 How about base 2 0 0 1 1 10 2 11 3 100 101 110 111 4 5 6 7 1000 1001 1010 1011 1100 1101 1110 1111 8 9 10 11 12 13 14 15 Binary Decimal 7 Derive Numbers in Base 2 Decimal base 10 25 10 Binary base 2 11001 2 Exercise 2 25 2 12 2 6 2 3 1 1 0 0 1 8 Base 2 Decimal base 10 Exercise 982 10 Binary base 2 1111010110 2 9 Base 8 Decimal base 10 Exercise 982 10 Octal base 8 1726 8 10 Base 16 Decimal base 10 982 10 Hexadecimal base 16 Hey what do we do when we count to 10 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 a b c d e f 11 Base 16 982 10 3d6 16 3d6 16 can be written as 0011 1101 0110 2 We use Base 16 or Hex a lot in computer world Ex A 32 bit address can be written as 0xfe8a7d20 0x is an abbreviation of Hex Or in binary form 1111 1110 1000 1010 0111 1101 0010 0000 12 Number Examples with Different Bases Decimal base 10 982 10 Binary base 2 01111010110 2 Others examples base 9 1321 9 base 11 813 11 base 17 36d 17 Octal base 8 1726 8 Hexadecimal base16 3d6 16 13 Convert between different bases Convert a number base x to base y e g 0100111 2 to 6 First convert from base x to base 10 if x 10 Then convert from base 10 to base y 0100111 0 26 1 25 0 24 0 23 1 22 1 21 1 20 39 6 39 3 6 6 1 0 0100111 2 103 6 14 Base b Addition Negative Number Representation Options Sign magnitude One s Complement Two s Complement we use this in this course 16 Sign magnitude Use the most significant bit MSB to indicate the sign 0 positive 1 negative Problem Representing zeros Do not work in computation We will NOT use it in this course 0 000 1 001 2 010 3 011 3 111 2 110 1 101 0 100 17 One s Complement Complement flip each bit in a binary number Problem Representing zeros Do not always work in computation Ex 111 001 000 Incorrect We will NOT use it in this course 0 000 1 001 2 010 3 011 3 100 2 101 1 110 0 111 18 Two s Complement Complement flip each bit in a binary number and adding 1 1 with overflow ignored Work in computation perfectly We will use it in this course 3 011 3 One s complement 101 One s complement 100 010 Add 1 3 101 Add 1 3 011 19 Two s Complement Complement flip each bit in a binary number and adding 1 1 with overflow ignored Work in computation perfectly We will use it in this course 0 1 001 1 One s complement 011 Add 1 100 The same 100 represents both 4 and 4 which is no good 111 2 010 2 100 000 110 3 011 3 101 100 20 Two s Complement Complement flip each bit in a binary number and adding 1 1 with overflow ignored Work in computation perfectly We will use it in this course 100 One s complement 011 Add 1 100 MSB 1 for negative Number thus 100 represents 4 0 000 1 001 1 11 1 2 010 2 11 0 3 011 3 10 1 4 1 0 0 21 Range of Numbers An N bit number Unsigned 0 2N 1 Signed 2N 1 2N 1 1 Example 4 bit 0000 0 1110 8 Unsigned numbers 1111 15 0111 7 Signed numbers 22 Binary Computation 010001 17 16 1 001011 11 8 2 1 011100 28 16 8 4 Unsigned arithmetic 010001 17 16 1 101011 43 32 8 2 1 111100 60 32 16 8 4 Signed arithmetic w 2 s complement 010001 17 16 1 101011 21 2 s complement 010101 21 111100 2 s complement 000100 4 i e 4 23 Binary Computation Unsigned arithmetic 101111 47 The carry is 011111 31 discarded 001110 78 Due to overflow note that 62 cannot be represented by a 6 bit unsigned number Signed arithmetic w 2 s complement 101111 17 since 2 s complement 010001 The carry is 011111 31 discarded 001110 14 24 BACKUP Application of Two s Complement The first Pocket Calculator Curta used Two s complement method for subtraction First complement the subtrahend Fill the left digits to be the same length of the minuend Complemented number 9 digit 4 s complement 5 7 s complement 2 0 s complement 9 Add 1 to the complemented number Perform an addition with the minuend 26 Examples 13 7 Two s complement of 07 92 1 93 13 93 06 ignore the leftmost carry digit 817 123 Two s complement of 123 876 1 877 817 877 694 ignore the leftmost carry digit 78291 4982 Two s complement of 04982 95017 1 95018 78291 95018 73309 ignore the leftmost carry digit 27
View Full Document