| OCR Text |
Show 91 A simple way of implementing round to nearest is by adding 1/2 to the LSB and truncating all bits to the right of the LSB. For example, if we wanted to round 76.234 to two places after decimal, we would add 0.5 at the LSB giving 76.239 and chopping off 9 gives us 76.23 which is what we want. If the number were 76.236 we would get 76.241 and removing 1 gives us 76.24 which is what we want. Now what if the number were 76.225? If we use the above algorithm, then we would get 76.23 which is incorrect according to the IEEE standard. The correct answer should be 76.22. However, if the original number were 76.245 then our method would still work. Although resolving the tie cases for decimal numbers complicates matters, we are lucky that we are dealing with only binary numbers. The above method can still be used. The only modification is, once the tie case has been determined(by using a sticky bit to be discussed later) simply force the LSB to a 0 which is an even number. Based on the above discussion we can come up with a fairly intuitive algorithm for round to nearest/up, whose data flow is shown in Figure 5.1. A direct implementation of this would be quite slow as we have two additions in series- a 48 bit addition followed by a 26 bit final addition for rounding. In the next few sections it will be shown how these two additions can be merged into one. This will also help in reducing the size of the CPA to 26 bits. 5.3 Modifications to the Basic Algorithm In this section Santoro's stepwise refinement is followed to improve the algorithm shown in Figure 5.1 so that we get a fast and efficient implementation. The first thing to note is that a 1 always gets added for the rounding step. It is only the position where it gets added that is different, depending on the overflow. It is assumed that the sum and carry bits are in the CSA form are such that they would produce no overflow. In that case a 1 gets added at the 2-n position, hence forth referred to the r (round) bit position. Then basically an n+2 (in our case, |