Exact dyadic values #
A FloatLib.Numerics.Dyadic stores a sign, natural significand, and integral power-of-two scale.
Arithmetic and rounding can work on these fields without rational normalization.
Lean core's _root_.Dyadic, defined in Init.Data.Dyadic.Basic, normalizes nonzero values to
an odd integer times a power of two and has a single zero. The FloatLib record retains an
unnormalized significand and scale, together with a separate sign for IEEE signed-zero rules.
Its toRat identifies both zero signs; formats with a single zero discard that sign on encoding.
toCore converts to Lean's normalized carrier and preserves the rational value.
The carrier provides integer conversions and rational denotation. Arithmetic and order follow in their respective modules.
An exact signed integer multiple of an integral power of two.
significand = 0 denotes zero for every sign and exponent. Families that distinguish signed zero
can preserve that distinction in their semantics and rounding rules; toRat identifies both zeros.
- negative : Bool
truemeans negative. - significand : ℕ
Nonnegative integer significand.
- exponent : ℤ
Integral power-of-two scale.
Instances For
Instances For
Exact dyadics are equal when all three stored scalar fields are equal.
Exact zero with the conventional nonnegative canonical fields.
Instances For
Canonical exact zero has a zero significand.
Canonical exact zero uses exponent zero.
Represent coefficient * 2 ^ exponent by extracting the integer's sign and magnitude.
Fixed-point accumulators use this conversion before rounding, without rational normalization.
Instances For
Signed integer significand before the power-of-two scale is applied.
Instances For
Taking the absolute value of the signed significand recovers its stored magnitude.
Exact rational denotation of a dyadic value.
Instances For
Normalize into Lean's dyadic carrier, identifying the two representations of zero.
Instances For
Reverse the sign, including the sign of zero. Formats with a single zero apply that policy when encoding the result.
Instances For
Negation preserves the stored significand.