This preview shows page 1. Sign up to view the full content.
Unformatted text preview: matching 2.4. FLOATING POINT
Mode Round-to-even Round-toward-zero Round-down Round-up $1.40 $1 $1 $1 $2 $1.60 $2 $1 $1 $2 $1.50 $2 $1 $1 $2 $2.50 $2 $2 $2 $3 $–1.50 $–2 $–1 $–2 $–1 75 Figure 2.25: Illustration of Rounding Modes for Dollar Rounding. The ﬁrst rounds to a nearest value, while the other three bound the result above or below. value Ü¼ that can be represented in the desired ﬂoating-point format. This is the task of the rounding operation. The key problem is to deﬁne the direction to round a value that is halfway between two possibilities. For example, if I have $1.50 and want to round it to the nearest dollar, should the result be $1 or $2? An alternative approach is to maintain a lower and an upper bound on the actual number. For example, we could determine representable values Ü and Ü· such that the value Ü is guaranteed to lie between them: Ü Ü Ü· . The IEEE ﬂoating-point format deﬁnes four different rounding modes. The default method ﬁnds a c...
View Full Document
- Spring '10
- The American