pub fn ulp(x: &DBig) -> OxiNumResult<DBig>Expand description
Return the unit in the last place of x at its current precision.
This is dashu_float::FBig::ulp re-exported as a free function for
API symmetry with epsilon and with_precision. The result is
a positive value whose least significant decimal position matches
x (i.e. ulp(x) is the smallest positive d such that x + d
is the next representable neighbour of x).
§Errors
Returns OxiNumError::Precision if x carries unlimited
precision (x.precision() == 0). In that case ulp is
undefined — dashu_float::FBig::ulp would itself panic, which we
surface as a recoverable error here.
§Examples
use std::str::FromStr;
use oxinum_float::{precision::ulp, DBig};
let x = DBig::from_str("1.23").expect("parse 1.23");
let u = ulp(&x).expect("finite precision");
assert_eq!(u, DBig::from_str("0.01").expect("parse 0.01"));
// ulp does not change the carried precision.
assert_eq!(u.precision(), x.precision());