Expand description
Built-in rounding modes of the floating numbers.
§Rounding Error
For different rounding modes, the Rounding error in the output of operations tells the error range, as described in the table below.
| Mode | Rounding | Error (truth - estimation) Range |
|---|---|---|
| Zero | NoOp | (-1 ulp 0) or (0, 1 ulp)* |
| Away | AddOne | (-1 ulp, 0) |
| Away | SubOne | (0, 1 ulp) |
| Down | SubOne | (0, 1 ulp) |
| Up | AddOne | (-1 ulp, 0) |
| HalfAway | AddOne | [-1/2 ulp, 0) |
| HalfAway | NoOp | (-1/2 ulp, 1/2 ulp) |
| HalfAway | SubOne | (0, 1/2 ulp] |
| HalfEven | AddOne | [-1/2 ulp, 0) |
| HalfEven | NoOp | [-1/2 ulp, 1/2 ulp] |
| HalfEven | SubOne | (0, 1/2 ulp] |
*: Dependends on the sign of the result
Structs§
- Round away from 0
- Round toward -∞
- Round to the nearest value, ties away from zero
- Round to the nearest value, ties are rounded to an even value. (default mode for decimal float)
- Round toward +∞
- Round toward 0 (default mode for binary float)