@bin_float.BinFloat
This page tracks the current repository implementation and is written as the 0.2.0 API baseline.
Representation
Finite values are stored as:
significand * 2^exponent2
with an attached working precision.
Constructors and Stored Form
BinFloat::makeBinFloat::zeroBinFloat::oneBinFloat::infBinFloat::nanBinFloat::from_intBinFloat::from_bigintBinFloat::from_floatBinFloat::from_double
Notes:
- Public finite constructors normalize the stored representation.
compareaborts onNaN.sign()currently returnsSign::ZeroforNaN.
Access, Normalization, and Comparison
classifyprecisionsignsignificandexponent2is_zeronormalizedwith_precisionulpcompareminmaxclamp
Notes:
clampaborts if the bounds are unordered orNaN.ulp()returnsNaNon non-finite inputs.
Arithmetic and Conversion
negabsaddsubmuldiv
Supported operators:
+-*/- unary
-
Special-value notes:
NaNgenerally propagates.inf - infwith opposite signs becomesNaN.- Division by zero produces
inforNaNdepending on the numerator class.
Checked Arithmetic API
Direct exported helpers:
sqrt_bounds_for_precisionsqrt_for_precisioncompare_checkeddiv_checkedsqrtpow_int
Checked-behavior notes:
sqrt_bounds_for_precisionandsqrt_for_precisionrequire non-negative finite inputs.compare_checkedreturns a structured unordered-comparison error onNaN.div_checkedreturns a structured division-by-zero error.pow_intreturns a structured division-by-zero error for negative powers of zero.
Trait Surface
BinFloat currently implements:
@def.Floating@arithmetic.SqrtChecked@arithmetic.DivChecked@arithmetic.CompareChecked@arithmetic.PowNatChecked@arithmetic.PowIntCheckedEq,Add,Sub,Mul,Div,Neg,Show