Floating-Point Numbers #
This module assembles the full Flean.Float type (combining normal and
subnormal representations with infinities and NaN), the conversions toFloat
and toRat between rationals and floats, and the round-trip and rounding-error
correctness results such as to_float_to_rat.
Round a rational to a subnormal representation using the mode in scope.
Equations
- roundsub q = subnormalRound (roundFunction R) q
Instances For
A floating-point number of the format C: a signed infinity, NaN, a valid
normal representation, or a valid subnormal representation.
- inf
{C : FloatCfg}
: Bool → Float C
A signed infinity (
truefor negative). - nan
{C : FloatCfg}
: Float C
Not-a-number.
- normal
{C : FloatCfg}
(f : FloatRep C)
: f.validE → f.validM → Float C
A normal float, given by a representation with valid exponent and mantissa.
- subnormal
{C : FloatCfg}
(sm : SubnormRep C)
: sm.m < C.prec → Float C
A subnormal float, given by a representation with mantissa below precision.
Instances For
The exact rational value of a float (0 for infinities and NaN).
Equations
- toRat (Flean.Float.inf a) = 0
- toRat Flean.Float.nan = 0
- toRat (Flean.Float.normal f a a_1) = coeQ f
- toRat (Flean.Float.subnormal sm a) = subnormalToQ sm
Instances For
The largest finite float of the format C.
Equations
- maxFloat C = Flean.Float.normal (maxFloatRep C) ⋯ ⋯
Instances For
Negate a float by flipping the sign of each case.
Equations
- (Flean.Float.inf a).neg = Flean.Float.inf (decide ¬a = true)
- Flean.Float.nan.neg = Flean.Float.nan
- (Flean.Float.normal f a a_1).neg = Flean.Float.normal f.neg a a_1
- (Flean.Float.subnormal sm a).neg = Flean.Float.subnormal sm.neg a
Instances For
Round a rational toward negative infinity to a float.
Equations
Instances For
Round a rational to the nearest float (ties to even).