Skip to main content

Module precision

Module precision 

Source
Expand description

Precision-control helpers for the DBig wrapper.

These free functions wrap dashu-float precision primitives in an ergonomic, allocation-friendly API:

  • with_precision — rebind a value to a different working precision.
  • epsilon — the smallest positive unit representable at a given decimal precision, i.e. 10^(1 - precision) at the requested precision.
  • ulp — the unit in the last place of a specific value at the precision currently carried by its context.

All three operate on the decimal big-float (DBig = FBig<HalfAway, 10>) so callers do not have to spell out the underlying generic parameters.

§precision == 0 (unlimited)

dashu-float reserves a precision of 0 to mean unlimited. ulp is not meaningful in that regime and the underlying dashu_float::FBig::ulp panics in that case. We surface that as an OxiNumError::Precision instead — see ulp for details.

Functions§

epsilon
Return the smallest positive “unit” representable at the requested decimal precision, i.e. 10^(1 - precision) rounded to precision significant digits.
ulp
Return the unit in the last place of x at its current precision.
with_precision
Return x rebound to the requested decimal precision.