TorchLean API

FloatLib.Floats.Formats.DecimalInterchange.Datum

Decimal datums and cohorts #

A finite datum stores a sign, an integer coefficient, and a quantum exponent: its value is (-1)^sign * coefficient * 10^quantum. Trailing coefficient zeros are meaningful representation information. For example, 1 × 10^0 and 10 × 10^-1 are different datums in the same cohort.

This representation layer implements IEEE 754-2019 §§3.3 and 3.5. It supplies neither decimal arithmetic nor its rounding, preferred-exponent, or exception rules.

A decimal datum before selecting an interchange width. signaling = true represents a signaling NaN.

Instances For

    Representability at the selected precision and quantum range. NaN payloads have one fewer decimal digit than finite coefficients.

    Instances For

      The exact rational value of a finite datum; infinities and NaNs have no rational value. Signed zeros remain distinct datums even though both map to zero. Zero bypasses the radix power, so its quantum does not determine the size of an intermediate integer.

      Instances For
        theorem FloatLib.Floats.Formats.DecimalInterchange.Datum.toRat?_eq (d : Datum) :
        d.toRat? = match d with | finite s c q => some ((if s = true then -1 else 1) * c * 10 ^ q) | infinity negative => none | nan negative signaling payload => none

        The zero shortcut preserves the usual coefficient-times-radix-power interpretation.

        IEEE 754-2019 §§2.1 and 3.5.1 cohorts preserve the sign, including the sign of zero. Each infinity forms a singleton cohort. NaNs have no cohort. Width-specific cohorts restrict this relation to datums satisfying Valid.

        Instances For

          Biased exponent reconstructed by either decoder.

          Instances For