Chapter 2 Number System 1 Natural Numbers How
Chapter 2 Number System 1
Natural Numbers How many ones are there in 642? 600 + 40 + 2 ? Hundreds = 6 Tens = 4 Ones = 2 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 3 5
Positional Notation 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 This number is in base 10 The power indicates the position of the number 4 6
Positional Notation What if 642 has the base of 13? 2 + 6 x 13 = 6 x 169 = 1014 1 + 4 x 13 = 52 + 2 x 13º = 2 x 1 = 2 = 1068 in base 10 642 in base 13 is equivalent to 1068 in base 10 5 8 6
Positional Notation R is the base of the number As a formula: dn * Rn-1 + dn-1 * Rn-2 +. . . + d 2 * R + d 1 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 6 7
Common Number Systems System Base Symbols Decimal 10 0, 1, … 9 Binary 2 0, 1 Octal 8 0, 1, … 7 Hexadecimal 16 0, 1, … 9, A, B, … F 7
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. 8 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 9 10
Binary Numbering systems n Base: 2 n Digits: 0, 1 n 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 10
Conversions Decimal Octal Binary Hexadecimal 11
Octal to Decimal Octal Binary Hexadecimal 12
Octal to Decimal n Technique n Multiply each digit by 8 n, where n is the “weight” of the digit n The weight is the position of the digit, starting from 0 on the right n Add the results 13
Example 7248 => 4 x 80 = 2 x 81 = 7 x 82 = 4 16 448 46810 14
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 15 11
Converting Octal to Decimal n 278 = 2× 81+7× 80 = 16+7 = 2310 n 308 = 3× 81+0× 80 = 2410 n 43078 = 4× 83+3× 82+0× 81+7× 80= 224710 n Octal numbers uses digits 0 1 2 3 4 5 6 7 n 8 denotes octal base and 10 represents decimal base. 16
Hexadecimal to Decimal Octal Binary Hexadecimal 17
Hexadecimal to Decimal n Technique n Multiply each digit by 16 n, where n is the “weight” of the digit n The weight is the position of the digit, starting from 0 on the right n Add the results 18
Example ABC 16 => C x 160 = 12 x 1 = 12 B x 161 = 11 x 16 = 176 A x 162 = 10 x 256 = 2560 274810 19
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 20
Converting Hexadecimal to Decimal n 2816 = 28 h = 2× 161+8× 160 = 4010 n 2 F 16 = 2 Fh = 2× 161+15× 160 = 4710 n BC 1216 = BC 12 h = 11× 163+12× 162+1× 161+2× 160= 4814610 n Hexa numbers : 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F n 16 denotes Hax base and 10 represents decimal base. 21
Binary to Decimal Octal Binary Hexadecimal 22
Binary to Decimal n Technique n Multiply each digit by 2 n, where n is the “weight” of the bit n The weight is the position of the digit, starting from 0 on the right n Add the results 23
Example 1010112 => 1 1 0 1 x x x 20 21 22 23 24 25 = = = 1 2 0 8 0 32 4310 24
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 25 13
Converting Binary to Decimal n 101012 = 10101 b = 1× 24+0× 23+1× 22+0× 21+1× 20 = 16+4+1= (21)d n 101112 = 10111 b = 1× 24+0× 23+1× 22+1× 21+1× 20 = 16+4+2+1= (23)d n 1000112 = 100011 b = 1× 25+0× 24+0× 23+0× 22+1× 21+1× 20 =32+2+1= (35)d n Binary numbers uses only 0 and 1 digits. n b denotes binary base and d represents decimal base. 26
Other Conversions wrt Binary System Octal Binary Hexadecimal 27
Binary to Octal Conversion (cont. ) Three-bit Group 000 001 010 011 100 101 110 111 Decimal Digit Octal Digit 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 28
Binary to Octal Conversion n Since the maximum value represented in 3 bit is equal to: 23 – 1 = 7 n i. e. using 3 bits we can represent values from 0 – 7 which are the digits of the Octal numbering system. n Thus, three binary digits can be converted to one octal digit and visa versa. 29
Binary to Octal • Groups of Three (from right) • Convert each group 10101011 10 101 011 2 5 3 10101011 is 253 in base 8 30 17
Binary to Octal Conversion Ex : Convert 101001102 = 110 = 6 100 = 4 010 = 2 8 ( pad empty digits with 0) 101001102 = 2468 31
Octal to Binary Conversion Ex : Convert 7428 = 2 7 = 111 4 = 100 2 = 010 7428 = 111 100 0102 32
Binary to Hexa conversion Four-bit Group 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 Decimal Digit 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Hexadecimal Digit 0 1 2 3 4 5 6 7 8 9 A B C D E F 33
Binary to Hexa Conversion n Since the maximum value represented in 4 bit is equal to: 24 – 1 = 15 n i. e. using 4 bits we can represent values from 0 – 15 which are the digits of the Hexadecimal numbering system. n Thus, Four binary digits can be converted to one Hexadecimal digit. 34
Converting Binary to Hexadecimal • Groups of Four (from right) • Convert each group 10101011 1010 1011 A B 10101011 is AB in base 16 35 18
Binary to Hexa Conversion Ex : Convert 101001102 = 16 0110 = 6 1010 = A 101001102 = A 616 36
Hexa to Binary Conversion Ex : Convert 3 D 916 = 2 3 = 0011 D = 1101 9 = 1001 3 D 916 = 0011 1101 10012 37
Converting Decimal to other System Decimal Octal Binary Hexadecimal 38
Decimal to Binary n Technique n Divide by two, keep track of the remainder n First remainder is digit 0 (LSB, least-significant bit) n Second remainder is digit 1 n Etc. 39
Example 12510 = ? 2 2 125 2 62 2 31 2 15 7 2 3 2 1 2 0 1 1 1 12510 = 11111012 40
Decimal to Octal n Technique n Divide by 8 n Keep track of the remainder 41
Example 123410 = ? 8 8 8 1234 154 19 2 0 2 2 3 2 123410 = 23228 42
Decimal to Hexadecimal n Technique n Divide by 16 n Keep track of the remainder 43
Example 123410 = ? 16 16 1234 77 4 0 2 13 = D 4 123410 = 4 D 216 44
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 45 21
- Slides: 45