fn ulp<F: FixedPointNumber>() -> FExpand description
Returns the smallest positive increment representable by the fixed-point generic
[FixedPointNumber].
For a fixed-point number defined as:
value = inner / DIVthe ULP equals 1 / DIV.
§Behavior
- Uses
FixedPoint::from_inner(1)to construct the smallest step value. - Useful as a numerical tolerance in convergence or rounding checks.
§Example
ⓘ
let ulp_val = ulp::<FixedU128>();
assert_eq!(ulp_val, FixedU128::from_inner(1)); // represents 1e-18 if DIV = 1e18§Notes
- The exact decimal size of the ULP depends on
FixedPoint::DIV. - If
DIV = 10^6, thenULP = 1e-6. - Works for all fixed-point types whose
InnerimplementsFrom<u8>.