TorchLean API

FloatLib.Floats.Formats.Posit.Arithmetic.Limb.Decode.Runtime

Direct two-limb posit candidate decoding #

The two-limb posit decoder reads encodings stored in native words. Regime scans stay in fixed-width words, and conversion to Nat is delayed until exact dyadic fields are constructed. Refinement theorems live in Decode.Proof.

@[inline]

Test whether both limbs of a two-word encoding are zero.

Instances For
    @[inline]

    Read one bit from a two-word value using least-significant-bit numbering.

    Each branch delegates to the native-word reader, keeping the executable path to a shift, mask, and comparison instead of constructing a BitVec view.

    Instances For
      @[inline]

      Retain the low width bits of a two-limb value.

      The value is zero-extended outside its 128-bit carrier, so requesting at least 128 bits returns the complete value.

      Instances For
        @[inline]

        Bitwise complement of both native limbs.

        Instances For
          @[inline]

          Count leading zeroes in the low width bits of a two-limb value.

          The executable path masks once and uses the native logarithm of the high or low nonzero limb.

          Instances For
            @[inline]

            Count a leading run in the low width bits of a two-limb value.

            Zero runs use one masked native logarithm at every width. One runs use the complemented carrier through width 128; at wider widths the zero extension makes the leading bit zero immediately.

            Instances For
              @[inline]

              Eliminate a nonnegative candidate into native significand and exact exponent fields.

              The full significand remains in two machine limbs. Only the at-most-two-bit stored exponent is converted to Nat, matching the standardized posit descriptor without constructing an intermediate dyadic record.

              Instances For
                @[inline]

                Decode a nonnegative candidate into the shared exact-dyadic carrier.

                This proof-facing view is defined through withNonnegativeFields; optimized arithmetic consumes the same decoder through its native continuation interface.

                Instances For

                  Direct decoding of complete stored words #

                  @[inline]

                  Test the stored sign bit without reconstructing the mathematical code.

                  Instances For
                    @[inline]

                    Unsigned magnitude of one complete two-limb posit encoding.

                    Negative posit codes use exact-width two's complement. Complementation and increment stay in the two native limbs; lowBits removes the carrier bits above narrower formats. The result crosses to Nat only once, when nonnegativeDyadicAt constructs the shared exact significand.

                    Instances For
                      @[inline]

                      Decode a known finite, nonzero posit code through the two-limb field decoder.

                      The caller handles exceptional values. Sign extraction, magnitude extraction, and regime inspection use the two native limbs; the result stores the significand in the shared dyadic carrier.

                      Instances For
                        @[inline]

                        Eliminate a complete stored posit word into native dyadic fields.

                        NaR selects onNaR; zero and every finite value call the continuation. Sign extraction, two's-complement magnitude recovery, regime decoding, and significand construction all remain inside the two-limb carrier.

                        Instances For
                          @[inline]

                          Eliminate two stored posit words through one shared native-field interface.

                          Instances For
                            @[inline]

                            Eliminate three stored posit words through one shared native-field interface.

                            Instances For
                              @[inline]

                              Total direct decoder for one stored two-limb posit word.

                              NaR becomes none, the unique zero becomes exact dyadic zero, and every ordinary word uses the fixed-limb decoder.

                              Instances For