Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Number Systems Topics The Decimal Number System The Binary Number System Converting from Binary to Decimal Converting from Decimal to Binary The Hexadecimal Number System (r-1)’s and r’s compliment Number Systems The on and off states of the capacitors in RAM can be thought of as the values 1 and 0, respectively. Therefore, thinking about how information is stored in RAM requires knowledge of the binary (base 2) number system. BINARY NUMBER SYSTEM 5/8/2017 4 The Binary Number System The binary number system is also known as base 2. The values of the positions are calculated by taking 2 to some power. Why is the base 2 for binary numbers? Because we use 2 digits, the digits 0 and 1. The Binary Number System The binary number system is also a positional numbering system. Instead of using ten digits, 0 - 9, the binary system uses only two digits, 0 and 1. Example of a binary number and the values of the positions: 1 0 0 1 1 0 1 26 25 24 23 22 21 20 Converting from Binary to Decimal 1 0 0 1 1 0 1 26 25 24 23 22 21 20 20 = 1 21 = 2 22 = 4 23 = 8 24 = 16 25 = 32 26 = 64 decimal=(77)10 1 X 20 = 1 0 X 21 = 0 1 X 22 = 4 1 X 23 = 8 0 X 24 = 0 0 X 25 = 0 1 X 26 = 64 DECIMAL NUMBER SYSTEM The Decimal Number System The decimal number system is also known as base 10. The values of the positions are calculated by taking 10 to some power. Why is the base 10 for decimal numbers? Because we use 10 digits, the digits 0 through 9. The Decimal Number System The decimal number system is a positional number system. Example: 4210 = 1 0 1 0 1 0 2 The Decimal Number System Converting From Decimal to Binary Make a list of the binary place values up to the number being converted. Perform successive divisions by 2, placing the remainder of 0 or 1 in each of the positions from right to left. Continue until the quotient is zero OCTAL NUMBER SYSTEM 5/8/2017 13 Octal Number System (Base-8) The octal number system uses EIGHT values to represent numbers. The values are,0 1 2 3 4 5 6 7. 5/8/2017 14 Convert octal to decimal. Example: (264)8 Each column represents a power of 8, 264 becomes ..... 4 * 80 = 4 6 * 81 = 48 2 * 82 = 128 adding the results together gives 18010 5/8/2017 15 DECIMAL TO OCTAL Example: convert (177)10 to octal 177 / 8 = 22 remainder is 1 22 / 8 = 2 remainder is 6 2 / 8 = 0 remainder is 2 Answer = (2 6 1)8 Note: the answer is read from bottom to top as (261)8, the same as with the binary case. 5/8/2017 16 Working with Large Numbers 0101000010100111 = ? Humans can’t work well with binary numbers; there are too many digits to deal with. Memory addresses and other data can be quite large. Therefore, we sometimes use the hexadecimal number system. The Hexadecimal Number System The hexadecimal number system is also known as base 16. The values of the positions are calculated by taking 16 to some power. Why is the base 16 for hexadecimal numbers ? Because we use 16 symbols, the digits 0 through 9 and the letters A through F. The Hexadecimal Number System Binary Decimal 0 1 10 11 100 101 110 111 1000 1001 Hexadecimal Binary Decimal Hexadecimal 0 0 1010 10 A 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1011 1100 1101 1110 1111 11 12 13 14 15 B C D E F The Hexadecimal Number System Example of a hexadecimal number and the values of the positions: 3 C 8 B 0 5 1 166 165 164 163 162 161 160 Conversion of hex to decimal ( base 16 to base10) Example: convert (F4C)16 to decimal =>(F x 162) + (4 x 161) + (C x 160) => (15 x 256) + (4 x 16) + (12 x 1) 5/8/2017 21 Conversion of decimal to hex ( base 10 to base 16) Example: convert (4768)10 to hex. => 4768 / 16 = 298 remainder 0 =>298 / 16 = 18 remainder 10 (A) =>18 / 16 = 1 remainder 2 =>1 / 16 = 0 remainder 1 Answer: (1 2 A 0)16 Note: the answer is read from bottom to top , same as with the binary case. 5/8/2017 22 Octal to hexadecimal conversion The conversion is made in two steps using binary as an intermediate base. Octal is converted to binary and then binary to hexadecimal, grouping digits by fours, which correspond each to a hexadecimal digit. For instance, convert (1057)8 to hexadecimal: To binary: 1 0 5 7 001 000 101 111 Then to hexadecimal: 5/8/2017 0010 0010 1111 2 2 F 23 REPRESENTATION OF NUMBERS COMPLEMENT OF NUMBERS Two types of complements for base R number system: R's complement and (R-1)'s complement The (R-1)'s Complement Subtract each digit of a number from (R-1) FOR DECIMAL NUMBERS (r-1)=9 and for binary numbers (r-1)=1 Example: 9's complement of 83510 is 16410 1's complement of 10102 is 01012(bit by bit complement operation) The (r – 1)’s complement of octal or hexadecimal numbers are obtained by subtracting each digit from 7 or F (decimal 15) respectively. (r’s) Complement The r’s complement is obtained by adding 1 to the (r – 1)’s complement since rn – N = [(rn – 1) – N] + 1. Thus the 10’s complement of the decimal 2389 is 7610 + 1 = 7611 and is obtained by adding 1 to the 9’s complement value. The 2’s complement of binary 101100 is 010011 + 1 = 010100 and is obtained by adding 1 to the 1’s complement value. 5/8/2017 27 Add 1 to the low-order digit of its (R-1)'s complement Example - 10's complement of 83510 is 16410 + 1 = 16510 - 2's complement of 10102 is 01012 + 1 = 01102