BINARY INTEGERS A binary integer x is a finite sequence of the digits 0 and 1, which we write symbolically as x = (amam−1 · · · a2a1a0)2 where I insert the parentheses with subscript ()2 in order to make clear that the number is binary. The above has the decimal equivalent x = am2m + am−12m−1 + · · · + a121 + a0 For example, the binary integer x = (110101)2 has the decimal value x = 25 + 24 + 22 + 20 = 53 The binary integer x = (111 · · · 1)2 with m ones has the decimal value x = 2m−1 + · · · + 21 + 1 = 2m − 1 DECIMAL TO BINARY INTEGER CONVERSION Given a decimal integer x we write x = (amam−1 · · · a2a1a0)2 = am2m + am−12m−1 + · · · + a121 + a0 Divide x by 2, calling the quotient x1. The remainder is a0, and x1 = am2m−1 + am−12m−2 + · · · + a120 Continue the process. Divide x1 by 2, calling the quotient x2. The remainder is a1, and x2 = am2m−2 + am−12m−3 + · · · + a220 After a finite number of such steps, we will obtain all of the coefficients ai, and the final quotient will be zero. Try this with a few decimal integers. EXAMPLE The following shortened form of the above method is convenient for hand computation. Convert (11)10 to binary. √ b2 11c = √ 5 = x1 a0 = 1 b2 5c = √ 2 = x2 a1 = 1 b2 2c = √ 1 = x3 a2 = 0 b2 1c = 0 = x4 a3 = 1 In this, the notation bbc denotes the largest integer √ ≤ b, and the notation 2 n denotes the quotient resulting from dividing 2 into n. From the above calculation, (11)10 = (1011)2. BINARY FRACTIONS A binary fraction x is a sequence (possibly infinite) of the digits 0 and 1: x = (.a1a2a3 · · · am · · · )2 = a12−1 + a22−2 + a32−3 + · · · For example, x = (.1101)2 has the decimal value x = 2−1 + 2−2 + 2−4 = .5 + .25 + .0625 = 0.8125 Recall the formula for the geometric series n X 1 − rn+1 i r = , 1−r i=0 r 6= 1 Letting n → ∞ with |r| < 1, we obtain the formula ∞ X i=0 ri = 1 , 1−r |r| < 1 Using this, (.0101010101010 · · · )2 = 2−2 + 2−4 + 2−6 + · · · ³ ´ −2 −2 −4 1 + 2 + 2 + ··· = 2 which sums to the fraction 1/3. Also, (.11001100110011 · · · )2 = 2−1 + 2−2 + 2−5 + 2−6 + · · · 8. and this sums to the decimal fraction 0.8 = 10 DECIMAL TO BINARY FRACTION CONVERSION In x1 = (.a1a2a3 · · · am · · · )2 = a12−1 + a22−2 + a32−3 + · · · we multiply by 2. The integer part will be a1; and after it is removed we have the binary fraction x2 = (.a2a3 · · · am · · · )2 = a22−1 + a32−2 + a42−3 + · · · Again multiply by 2, obtaining a2 as the integer part of 2x2. After removing a2, let x3 denote the remaining number. Continue this process as far as needed. For example, with x = 15 , we have x1 = .2; 2x1 = .4; x2 = .4 and a1 = 0 2x2 = .8; x3 = .8 and a2 = 0 2x3 = 1.6; x4 = .6 and a2 = 1 Continue this to get the pattern (.2)10 = (.00110011001100 · · · )2 ADDITION TABLE + 1 10 11 100 101 1 10 11 100 101 110 11 100 101 110 111 10 110 111 1000 11 100 101 111 1000 1001 100 101 110 101 110 111 1000 1001 1010 MULTIPLICATION TABLE × 1 10 11 100 101 1 1 10 11 100 101 10 100 110 1000 1010 10 11 110 1001 1100 1111 11 100 100 1000 1100 10000 10100 101 101 1010 1111 10100 11001