TorchLean API

FloatLib.Floats.Formats.Posit.Descriptor

Posit format descriptors #

A posit format has one sign bit and a tapered payload whose regime length depends on the encoded value. The Posit Standard (2022) fixes the maximum exponent field at two bits, so a standard format is selected only by its total width.

The descriptor is static in the Lean type. It therefore supports arbitrary widths without storing the width in every runtime value.

References #

A validated, statically configured Posit Standard encoding.

  • bits :

    Total encoded width, including the sign bit.

  • bits_ge_two : 2 self.bits

    The Posit Standard requires at least two total bits.

Instances For
    @[inline]

    Number of encoded bits below the sign bit.

    Instances For
      @[inline]

      Index of the sign bit in least-significant-bit numbering.

      Instances For
        @[inline]

        Natural-number bit mask containing only the sign bit.

        Instances For
          @[inline]

          Unsigned encoding of the exact posit value one.

          Instances For
            @[inline]

            Modulus of the exact-width unsigned encoding.

            Instances For
              @[inline]

              Maximum number of exponent bits available after the regime terminator.

              Instances For
                @[inline]

                Binary exponent contributed by one unit of regime value.

                Instances For
                  @[simp]

                  One regime unit contributes 2 ^ exponentBits to the decoded binary exponent.

                  @[inline]

                  The same standardized posit family at one additional bit of precision.

                  Section 4.1 of the standard defines an n-bit rounding boundary using an (n + 1)-bit posit, so this descriptor transformation is part of the exact rounding definition rather than an implementation convenience.

                  Instances For
                    @[simp]

                    Adding one encoded bit adds exactly one bit to the tapered payload.

                    @[simp]

                    Adding one encoded bit shifts the sign mask left by one place.

                    Every valid posit has at least one payload bit.

                    The unique sign-bit mask is nonzero.

                    At least the codes zero and one lie below the sign-bit boundary.

                    The exact-one encoding is nonzero.

                    The exact-one encoding lies in the positive finite half of the word space.

                    The sign bit is strictly below the exact-width modulus.

                    The complete unsigned modulus is twice the mask containing the sign bit.

                    def FloatLib.Floats.Formats.Posit.Format.ofBits (bits : ) (bits_ge_two : 2 bits := by decide) :

                    Construct a Posit Standard descriptor from its total encoded width.

                    Instances For