Four Rounding Modes
Normalized result has the form:
“1.f1f2...fn r s
”.
The round bit r
and sticky bit s
appear after the last fraction bit fn
.
IEEE 754 standard specifies four modes of rounding:
- Round to nearest even:
- It is the default rounding mode.
Increment result if: (
rs
= “11”) or (rs
= “10” and fn
= ‘1’).
Otherwise, truncate result significand to 1.f1f2...fn
.
- Round toward +∞ (rounding up):
- Increment result if sign is positive and
r
or s
= ‘1’.
- Round toward -∞ (rounding down):
- Increment result if sign is negative and
r
or s
= ‘1’.
- Round toward 0:
- It always truncates the result.
For example, round the following result by using IEEE 754 rounding modes:
–1.11111111111111111111111 0 1 × 2-7
where the round and sticky bits are in blue and red colors, respectively.
- Round to nearest even:
- Truncate it to
–1.11111111111111111111111×2-7
since r
= ‘0’.
- Round toward +∞:
- Truncate the result since it is negative.
- Round toward -∞:
- Increment it to
–10.00000000000000000000000×2-7
since negative and s
= ‘1’.
Renormalize and increment exponent (because of carry).
Final rounded result is –1.00000000000000000000000×2-6
.
- Round toward 0:
- Always truncate.