pub struct Interval {
pub lo: Number,
pub hi: Number,
}Expand description
Closed interval [lo, hi] with outward rounding on operations.
EMPTY is encoded as lo > hi (specifically lo = +∞,
hi = -∞). ENTIRE is (-∞, +∞). Construction helpers normalize
these for you.
Fields§
§lo: Number§hi: NumberImplementations§
Source§impl Interval
impl Interval
Sourcepub fn new(lo: Number, hi: Number) -> Self
pub fn new(lo: Number, hi: Number) -> Self
Closed interval [lo, hi]. NaN endpoints or lo > hi collapse
to Self::EMPTY so downstream rules don’t have to special-
case malformed input.
pub fn is_empty(&self) -> bool
pub fn is_entire(&self) -> bool
pub fn contains_zero(&self) -> bool
Sourcepub fn intersect(self, other: Self) -> Self
pub fn intersect(self, other: Self) -> Self
[max(self.lo, other.lo), min(self.hi, other.hi)]. Empty if
the result is malformed — this is the right semantics for
FBBT’s “narrow against the constraint” step.
Sourcepub fn hull(self, other: Self) -> Self
pub fn hull(self, other: Self) -> Self
Convex hull [min(lo, lo), max(hi, hi)]. Empty if both inputs
are empty.
pub fn add(self, rhs: Self) -> Self
pub fn sub(self, rhs: Self) -> Self
pub fn neg(self) -> Self
Sourcepub fn div(self, rhs: Self) -> Self
pub fn div(self, rhs: Self) -> Self
Division — returns ENTIRE (rather than a split / extended
interval) when 0 ∈ rhs, since FBBT’s reverse rules elsewhere
can recover useful information without the union-of-intervals
complexity here.
Sourcepub fn pow_uint(self, n: u32) -> Self
pub fn pow_uint(self, n: u32) -> Self
[lo, hi]^n for non-negative integer n. Handles the
non-monotone case n even, 0 ∈ self correctly.
Sourcepub fn sqrt(self) -> Self
pub fn sqrt(self) -> Self
√[lo, hi]. Negative lo clipped to 0 (matches mathematical
domain). Empty input or fully-negative interval → EMPTY.
Sourcepub fn ln(self) -> Self
pub fn ln(self) -> Self
ln([lo, hi]) — monotone increasing on x > 0. lo ≤ 0 is
clipped to the smallest positive finite (return -∞ on the
low side). Fully-non-positive intervals → EMPTY.