TorchLean API

FloatLib.Floats.Formats.FixedPoint.Bounded.Configured.Conversion.Runtime

Bounded fixed-point conversion runtime #

Bounded fixed point offers three overflow policies. reject returns outOfRange, wrap reduces the rounded coefficient modulo 2 ^ width, and saturate clamps it to the signed range. Conversion.Instances installs checked conversion as the context-free default.

Overflow policy for conversion into bounded fixed point.

  • reject : OverflowPolicy

    Reject a rounded coefficient outside the signed destination range.

  • wrap : OverflowPolicy

    Reduce the rounded coefficient modulo 2 ^ width.

  • saturate : OverflowPolicy

    Clamp the rounded coefficient to the signed destination range.

Instances For
    @[inline]

    Whether the ties-to-even rounded coefficient fits the signed destination width.

    Instances For
      @[inline]
      def FloatLib.Floats.ExecFloat.BoundedFixedPoint.Conversion.finiteStatus {radix : Numerics.Radix} {fractionalDigits width : } (policy : OverflowPolicy) (exact : ) (rounded : BoundedFixedPoint radix fractionalDigits width) :

      Status for a delivered bounded fixed-point conversion.

      Instances For
        @[inline]
        def FloatLib.Floats.ExecFloat.BoundedFixedPoint.Conversion.quantizeFinite {radix : Numerics.Radix} {fractionalDigits width : } (policy : OverflowPolicy) (exact : ) :
        ConversionOutcome (BoundedFixedPoint radix fractionalDigits width)

        Quantize one finite rational according to the named bounded-overflow policy.

        Instances For
          @[inline]

          Convert a complete rational observation under an explicit bounded-overflow policy.

          Instances For
            def FloatLib.Floats.ExecFloat.BoundedFixedPoint.Conversion.coefficientSpec {radix : Numerics.Radix} {fractionalDigits width : } (policy : OverflowPolicy) (exact : ) (stored : ) :

            The signed output coefficient after nearest-even rounding and the selected overflow policy.

            The wrapping relation uses centered integer reduction, and saturation uses the signed range endpoints. Neither clause refers to a fixed-width encoding kernel.

            Instances For

              Conversion relates the delivered coefficient to integer rounding, range, wrap, and clamp.

              The status is retained in full. Rejection of a finite input occurs exactly when the nearest-even coefficient is out of range under reject; the other policies always deliver a value.

              Instances For
                @[instance_reducible]
                instance FloatLib.Floats.ExecFloat.BoundedFixedPoint.Conversion.exactDecoder {radix : Numerics.Radix} {fractionalDigits width : } :
                ExactDecoder (BoundedFixedPoint radix fractionalDigits width)

                Bounded fixed-point values decode canonically to their exact stored rational.