Module dashu::float::round::mode

source ·
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.

ModeRoundingError (truth - estimation) Range
ZeroNoOp(-1 ulp 0) or (0, 1 ulp)*
AwayAddOne(-1 ulp, 0)
AwaySubOne(0, 1 ulp)
DownSubOne(0, 1 ulp)
UpAddOne(-1 ulp, 0)
HalfAwayAddOne[-1/2 ulp, 0)
HalfAwayNoOp(-1/2 ulp, 1/2 ulp)
HalfAwaySubOne(0, 1/2 ulp]
HalfEvenAddOne[-1/2 ulp, 0)
HalfEvenNoOp[-1/2 ulp, 1/2 ulp]
HalfEvenSubOne(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)