

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Graded HW ASSIGNMENT 2: Repeating Binary Fractions
ASSIGNED: Thursday, 12 February, 2009 Due: Monday, 16 February, 2009
Background: Consider that ( 0. 1 ) 10 , which terminates as a decimal fraction, repeats as a binary frac- tion; that is, ( 0. 1 ) 10 = ( 0 .00011 0011 0011 0011) 2 (1)
To derive this result, we use ALG 1.3 from the course notes (Base 10 to Base b Fractions). On the other hand ( 1 / 3 ) 10 = 0. 3333310 = ( 0 .01 01 01 01) 2 (2)
repeats as both decimal and binary fractions, whereas
( 1 / 16 ) 10 = ( 0. 0625 ) 10 = ( 0. 0001 ) 2 (3)
terminates as both decimal and binary fractions.
Of interest in this assignment is the reverse process. That is, given a binary fraction, repeating or terminating, can we derive the corresponding decimal fraction, repeating or terminating? If the binary fraction terminates, the problem is easy. We simply move the “decimal point” n places to the right, just enough places to get a whole number, convert the whole number using ALG 1.1 (Horner’s method), and divide the result by 2n. On the other hand, if the binary fraction repeats, we have to be more clever.
It was shown in class that a repeating “decimal” fraction is really a geometric series in disguise. Geo- metric series are nice, because, although they are infinite, we can sum them exactly. In particular, the geometric series ∞
k= 0
ark^ = a + ar + ar^2 + ar^3 + ... =
a 1 − r
provided |r| < 1. Let’s illustrate by working backwards from Eq. 2. We do this by considering the value of each repetition of the block of repeated bits. Let B be the block size. In this example, two bits are repeated, so B = 2. Now consider each block in turn: Before proceeding further, see if you can fill
Block number Binary Value Decimal Value
... ... ...
Table 1: Repeating binary fractions as geometric series.
in the 4th row in the Table 1. Note that the Table is infinite, but by row 4 the pattern should be clear. Adding down the second and third columns, we get
( 0 .01 01 01 01) 2 = 1 / 4 + 1 / 4 × 2 −^2 + 1 / 4 ×−^4 + 1 / 4 × 2 −^6 + ... = 1 / 4 [ 1 + ( 1 / 4 ) + ( 1 / 4 )^2 + ( 1 / 4 )^3 + ...] (4)
The series on the right is geometric, with a = 1 /4 and r = 1 /4. Thus it converges to
a 1 − r
Voila! We’ve now successfully gone both directions in converting fractions between binary and decimal representations.
Assignment: Your job is to fill in Table 2 below and to notice patterns. For this purpose, recall that B represents the length of the block of repeating bits. So, B = 1 means that the repetition block has only 1 bit, (e.g., ( 0. 111111 ) 2 ), B = 2 means that the repetition block has 2 bits (e.g., (. 01010101 ) 2 ), and so on. For the moment, assume that only a single bit in the block can be non-zero, and let N denote its position in the block of the “1” bit. For the latter example immediately above, N = 2. Thus we have entered the value 1/3 obtained from Eqs. 4 and 5 in the column corresponding to B = 2 and in the row corresponding to N = 2. Note that the “x’s” in the Table denote impossible combinations. A couple of values have been computed for you so you will know if you are doing the assignment correctly.
2 x 1/ 3 x x 4 x x x 5 x x x x
Table 2: Interpreting repeating binary fractions.
GROUND RULES: You may work with others, but you are to turn in this assignment individually.