Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Chapter 2 Number Systems Consists of a set of symbols called digits and a set of relations such as +, -, x, /. RADIX OR BASE The total number of digits is the radix, or base of the system. Each position in the number is a power of the base. The power starts at 0 and increases by one as we move each position to the left of the radix point, and decreases by one as we move to the right of the radix point. Example: decimal number 2351.2318 ---------------------------------------------------2 3 5 1 . 2 3 1 8 ---------------------------------------------------10^3 10^2 10^1 10^0 10^-1 10^-2 10^-3 10^-4 powers increase by one powers decrease by one 10^3 10^2 10^1 10^0 X X X X 2 = 2000 3 = 300 5 = 50 1= 1 10^-1 10^-2 10^-3 10^-4 X 2 = .2 X 3 = .03 X 1 = .001 X 8 = .0008 = 2351.2318 BINARY NUMBER SYSTEM In the binary number system the radix is 2. The BInary digiTS (bits) can take on the values 0 or 1 --------------------------------------------------1 1 0 1 0 . 1 1 0 1 --------------------------------------------------2^4 2^3 2^2 2^1 2^0 2^4 2^3 2^2 2^1 2^0 X 1 = 16 X1= 8 X0= 0 X1= 2 X0= 0 2^-1 2^-2 2^-3 2^-4 2^-1 X 1 = .5 2^-2 X 1 = .25 2^-3 X 0 = 0 2^-4 X 1 = .0625 = 26.8125 Since each bit can have the values of 0 or 1, with two bit positions we can derive four (2^2) distinct patterns. In general, with n bits it is possible to have 2^n combinations of 0's and 1's, these combinations can take on the decimal values of 0 through (2^n - 1). BINARY/DECIMAL Binary value Decimal value --------------------------------------2^0 2^1 2^2 2^3 2^4 2^5 2^6 2^7 2^8 2^9 2^10 2^12 2^16 2^20 2^24 2^30 2^32 2^40 1 2 4 8 16 32 64 128 256 512 1024 ----------> 1 K 4096 65536 ----------> 64 K 1,048,576 ----------> 1 Megabyte 16,777,216 1.0737 E9 -------- > 1 Gigabyte 1,000 M 4.095 E9 1.0995 E12 --------- > 1 Terabyte 1,000 G OCTAL NUMBER SYSTEM In the octal number system the radix is 8. The digits can take the values of 0,1,2,3,4,5,6 or 7. ----------------------------------------------------4 7 5 . 3 4 ----------------------------------------------------8^2 8^1 8^0 8^2 X 4 = 256 8^1 X 7 = 56 8^0 X 5 = 5 8^-1 8^-2 8^-1 X 3 = .375 8^-2 X 4 = .0625 = 317.4375 Using the octal number system, with an n digit number there are 8 different combinations of digits possible. Which means 8 different numbers can be represented in the range of 0 through (8^n - 1). HEXIDECIMAL SYSTEM This number system has a radix of 16, so 16 digits are needed. For this system the numbers 0 - 9 are used and the letters A,B,C,D,E and F are used to represent the numbers 10 - 15. --------------------------------------------4 B E 1 . C 3 --------------------------------------------16^3 16^2 16^1 16^0 16^3 16^2 16^1 16^0 16^-1 16^-2 X 4 = 16384 X B(11) = 2816 X E(14) = 224 X1 = 1 16^-1 X C(12) = .75 16^-2 X 3 = .0117188 = 19425.7617188 Since each digit can have 16 different values with n digits there can be 16^n different numbers in the range 0 through (16^n - 1). In general, for any number system of radix (base) R, having n digits, there will be R^n different combinations having the values 0 through (R^n - 1). Also, the maximum value that a number can have is R^n - 1. Integers Binary -> Decimal (1 0 1 1)2 = ( ( (1 x 2 + 0) x 2 + 1) x 2) + 1 = (1x22 + 0x2 + 1) x 2 + 1 = (1x23 + 0x22 + 1x2) + 1 = 1x23 + 0x22 + 1x21 + 1x20 = 1x8 + 0x4 + 1x2 + 1x1 =8+0+2+1 = 11 Integers Base -> Decimal Result <- Most Significant Digit Multiply Result by Base and add next digit to right Repeat step 2 until least significant digit has been added Example: (672)8 == (442)10 Integers Decimal -> Base Result <- Decimal Number Divide Result by Base and save remainder Result <- Quotient Repeat step 2 until no more quotients Example: (442)10 == (672)8 Fractions Decimal -> Base Result <- Decimal Number Multiply Result by Base and save whole number Result <- Fraction Repeat step 2 until no fractions or significance exceeded Example: (0.62)10 == (0.4753)8 Fractions Base -> Decimal Divisor <- Denominator of LSD Treat Fraction as a whole number (that is, ignore decimal point) and convert Divide the result by the Divisor of Step 1 Example: (0.4753)8 == (0.619873)10