Chapter 2 Number System
Natural Numbers How many ones are there in 642? Hundreds = 6 Tens = 4 600 + 40 + 2 ? Hundreds = 6 Tens = 4 Ones = 2 4
Natural Numbers Aha! 642 is 600 + 40 + 2 in BASE 10 The base of a number determines the number of digits and the value of digit positions 5
Positional Notation 642 in base 10 positional notation is: Continuing with our example… 642 in base 10 positional notation is: 6 x 102 = 6 x 100 = 600 + 4 x 101 = 4 x 10 = 40 + 2 x 10º = 2 x 1 = 2 = 642 in base 10 The power indicates the position of the number This number is in base 10 6
Positional Notation What if 642 has the base of 13? 642 in base 13 is equivalent to 1068 in base 10 + 6 x 132 = 6 x 169 = 1014 + 4 x 131 = 4 x 13 = 52 + 2 x 13º = 2 x 1 = 2 = 1068 in base 10 8 6
Positional Notation dn * Rn-1 + dn-1 * Rn-2 + ... + d2 * R + d1 R is the base of the number As a formula: dn * Rn-1 + dn-1 * Rn-2 + ... + d2 * R + d1 n is the number of digits in the number d is the digit in the ith position in the number 642 is 63 * 102 + 42 * 10 + 21 7
Common Number Systems System Base Symbols Decimal 10 0, 1, … 9 Binary 2 0, 1 Octal 8 0, 1, … 7 Hexa- decimal 16 0, 1, … 9, A, B, … F
Binary Decimal is base 10 and has 10 digits: 0,1,2,3,4,5,6,7,8,9 Binary is base 2 and has 2 digits: 0,1 For a number to exist in a given number system, the number system must include those digits. For example, the number 284 only exists in base 9 and higher. 9
Bases Higher than 10 How are digits in bases higher than 10 represented? With distinct symbols for 10 and above. Base 16 has 16 digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E, and F 10
Binary Numbering systems Base: 2 Digits: 0, 1 binary number: 1101012 positional powers of 2: 25 24 23 22 21 20 decimal positional value: 32 16 8 4 2 1 binary number: 1 1 0 1 0 1
Conversions Decimal Octal Binary Hexadecimal
Octal to Decimal Decimal Octal Binary Hexadecimal
Octal to Decimal Technique Multiply each digit by 8n, where n is the “weight” of the digit The weight is the position of the digit, starting from 0 on the right Add the results
Example 7248 => 4 x 80 = 4 2 x 81 = 16 7 x 82 = 448 46810
Converting Octal to Decimal What is the decimal equivalent of the octal number 642? 6 x 82 = 6 x 64 = 384 + 4 x 81 = 4 x 8 = 32 + 2 x 8º = 2 x 1 = 2 = 418 in base 10 11
Converting Octal to Decimal 278 = 2×81+7×80 = 16+7 = 2310 308 = 3×81+0×80 = 2410 43078 = 4×83+3×82+0×81+7×80= 224710 Octal numbers uses digits 0 1 2 3 4 5 6 7 8 denotes octal base and 10 represents decimal base.
Hexadecimal to Decimal Octal Binary Hexadecimal
Hexadecimal to Decimal Technique Multiply each digit by 16n, where n is the “weight” of the digit The weight is the position of the digit, starting from 0 on the right Add the results
Example ABC16 => C x 160 = 12 x 1 = 12 B x 161 = 11 x 16 = 176 A x 162 = 10 x 256 = 2560 274810
Converting Hexadecimal to Decimal What is the decimal equivalent of the hexadecimal number DEF? D x 162 = 13 x 256 = 3328 + E x 161 = 14 x 16 = 224 + F x 16º = 15 x 1 = 15 = 3567 in base 10 Remember, the digits in base 16 are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
Converting Hexadecimal to Decimal 2F16 = 2Fh = 2×161+15×160 = 4710 BC1216 = BC12h = 11×163+12×162+1×161+2×160= 4814610 Hexa numbers : 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F 16 denotes Hax base and 10 represents decimal base.
Binary to Decimal Decimal Octal Binary Hexadecimal
Binary to Decimal Technique Multiply each digit by 2n, where n is the “weight” of the bit The weight is the position of the digit, starting from 0 on the right Add the results
Example 1010112 => 1 x 20 = 1 1 x 21 = 2 0 x 22 = 0 1 x 23 = 8 0 x 24 = 0 1 x 25 = 32 4310
Converting Binary to Decimal What is the decimal equivalent of the binary number 1101110? 1 x 26 = 1 x 64 = 64 + 1 x 25 = 1 x 32 = 32 + 0 x 24 = 0 x 16 = 0 + 1 x 23 = 1 x 8 = 8 + 1 x 22 = 1 x 4 = 4 + 1 x 21 = 1 x 2 = 2 + 0 x 2º = 0 x 1 = 0 = 110 in base 10 13
Converting Binary to Decimal 101012 = 10101b = 1×24+0×23+1×22+0×21+1×20 = 16+4+1= (21)d 101112 = 10111b = 1×24+0×23+1×22+1×21+1×20 = 16+4+2+1= (23)d 1000112 = 100011b = 1×25+0×24+0×23+0×22+1×21+1×20 =32+2+1= (35)d Binary numbers uses only 0 and 1 digits. b denotes binary base and d represents decimal base.
Other Conversions wrt Binary System Octal Binary Hexadecimal
Binary to Octal Conversion (cont.) Three-bit Group Decimal Digit Octal Digit 000 0 0 001 1 1 010 2 2 011 3 3 100 4 4 101 5 5 110 6 6 111 7 7
Binary to Octal Conversion Since the maximum value represented in 3 bit is equal to: 23 – 1 = 7 i.e. using 3 bits we can represent values from 0 –7 which are the digits of the Octal numbering system. Thus, three binary digits can be converted to one octal digit and visa versa.
Binary to Octal Groups of Three (from right) Convert each group 10101011 10 101 011 2 5 3 10101011 is 253 in base 8 17
Binary to Octal Conversion Ex : Convert 101001102 = 8 110 = 6 100 = 4 010 = 2 ( pad empty digits with 0) 101001102 = 2468
Octal to Binary Conversion Ex : Convert 7428 = 2 7 = 111 4 = 100 2 = 010 7428 = 111 100 0102
Binary to Hexa conversion Four-bit Group Decimal Digit Hexadecimal Digit 0000 0 0 0001 1 1 0010 2 2 0011 3 3 0100 4 4 0101 5 5 0110 6 6 0111 7 7 1000 8 8 1001 9 9 1010 10 A 1011 11 B 1100 12 C 1101 13 D 1110 14 E 1111 15 F
Binary to Hexa Conversion Since the maximum value represented in 4 bit is equal to: 24 – 1 = 15 i.e. using 4 bits we can represent values from 0 –15 which are the digits of the Hexadecimal numbering system. Thus, Four binary digits can be converted to one Hexadecimal digit.
Converting Binary to Hexadecimal Groups of Four (from right) Convert each group 10101011 1010 1011 A B 10101011 is AB in base 16 18
Binary to Hexa Conversion Convert 101001102 = 16 0110 = 6 1010 = A 101001102 = A616
Hexa to Binary Conversion Convert 3D916 = 2 3 = 0011 D = 1101 9 = 1001 3D916 = 0011 1101 10012
Converting Decimal to other System Octal Binary Hexadecimal
Decimal to Binary Technique Divide by two, keep track of the remainder First remainder is digit 0 (LSB, least-significant bit) Second remainder is digit 1 Etc.
Example 2 125 62 1 12510 = ?2 2 31 0 2 15 1 2 7 1 2 3 1 2 1 1 2 0 1 12510 = 11111012
Decimal to Octal Technique Divide by 8 Keep track of the remainder
Example 123410 = ?8 8 1234 154 2 8 19 2 8 2 3 8 0 2 123410 = 23228
Decimal to Hexadecimal Technique Divide by 16 Keep track of the remainder
Example 123410 = ?16 16 1234 77 2 16 4 13 = D 0 4 123410 = 4D216
Converting Decimal to Hexadecimal 222 13 0 16 3567 16 222 16 13 32 16 0 36 62 13 32 48 47 14 32 15 F E D 21