@ball_float.BallFloat
This page tracks the current repository implementation and is written as the 0.2.0 API baseline.
Semantics
BallFloat represents the enclosure:
center +/- radius
The implementation stores that enclosure as lower and upper BinFloat bounds and prefers correctness of containment over returning the narrowest possible interval.
Construction
BallFloat::newBallFloat::exactBallFloat::from_intBallFloat::from_bigintBallFloat::from_floatBallFloat::from_double
Constraints:
- The center must be finite.
- The radius must be finite and non-negative.
exact,from_float, andfrom_doubleabort on non-finite source values.
Notes:
- Center retuning widens the stored radius by the induced center displacement so the enclosure never shrinks.
- Radius quantization always rounds outward.
Accessors and Interval Shape
lower_boundupper_boundcenterradiusprecisionclassifysignis_boundedis_entirecontains_zeronormalizedwith_precision
Notes:
center()andradius()abort on unbounded intervals.- If the enclosure spans both negative and positive values,
sign()returnsSign::Zero. classify()reportsInfinityfor unbounded intervals.
Relations and Comparison
containsoverlapsseparated_fromdefinitely_ltdefinitely_ledefinitely_gtmaybe_eq
Notes:
- Relations are enclosure-oriented and intentionally do not pretend to be a scalar total order.
Arithmetic and Checked Capability Behavior
addsubmuldiv
Supported operators:
+-*/- unary
-
Checked-behavior notes:
- Checked division may widen to the whole-real enclosure when the divisor contains zero.
- Checked integer power preserves enclosure correctness and uses the same whole-real fallback for zero-containing inverse cases.
BallFloatdoes not implement scalarCompareChecked.- This pass does not expose non-integer power, transcendental functions, calculus, matrices, complex balls, or special functions.
Trait Surface
BallFloat currently implements:
@def.Floating@arithmetic.Contains@arithmetic.Overlaps@arithmetic.DefinitelyLt@arithmetic.DefinitelyLe@arithmetic.MaybeEq@arithmetic.DivChecked@arithmetic.PowNatChecked@arithmetic.PowIntCheckedEq,Add,Sub,Mul,Div,Neg,Show