TorchLean API

FloatLib.Numerics.Exact.Dyadic.Comparison.Runtime

Executable exact-dyadic comparison #

The general comparator aligns significands at a common exponent. The Internal.compareScalable variants first compare leading binary positions, avoiding shifts proportional to a potentially huge exponent gap. Comparison.Proof connects the field-level entry points and normalization tests to the general comparator; rational ordering laws are in Dyadic.Order.

@[inline]
def FloatLib.Numerics.Dyadic.Internal.compareNonzeroMagnitudes (leftSignificand : ) (leftExponent : ) (rightSignificand : ) (rightExponent : ) :

Compare two nonzero dyadic magnitudes without allocating across the full exponent gap.

Different leading binary positions decide the result immediately. Equal leading positions imply that exponent alignment shifts by no more than the difference between the two significand widths, even when the stored exponents themselves are enormous.

Instances For
    @[inline]
    def FloatLib.Numerics.Dyadic.Internal.compareScalableFields (leftNegative : Bool) (leftSignificand : ) (leftExponent : ) (rightNegative : Bool) (rightSignificand : ) (rightExponent : ) :

    Compare exact dyadic fields with alignment shifts bounded by significand widths.

    Zero and opposite-sign cases need no magnitude comparison. Same-sign nonzero inputs use their leading binary positions before any bounded alignment.

    Instances For
      @[inline]

      Record-based entry point for exponent-scalable exact-dyadic comparison.

      Instances For
        @[inline]
        def FloatLib.Numerics.Dyadic.compareFields (leftNegative : Bool) (leftSignificand : ) (leftExponent : ) (rightNegative : Bool) (rightSignificand : ) (rightExponent : ) :

        Compare exact dyadic scalar fields without first allocating either Dyadic record.

        Format-specific decoders often already expose sign, significand, and exponent separately. This entry point preserves that flattened representation through exact comparison.

        Instances For
          @[inline]

          Compare two exact dyadic values.

          The comparison aligns only to the smaller of the two exponents and then compares signed integers; it never converts through a host floating-point value.

          Instances For
            @[inline]
            def FloatLib.Numerics.Dyadic.compareNonnegativeFields (leftSignificand : ) (leftExponent : ) (rightSignificand : ) (rightExponent : ) :

            Compare two nonnegative significand/exponent pairs without constructing signed integers.

            Posit and unsigned binary rounding spend most comparisons in this domain. Because the common exponent is always one of the two input exponents, only the significand at the larger exponent needs shifting.

            Instances For
              @[inline]

              Executable strict comparison without conversion to Rat or a host floating-point value.

              Instances For
                @[inline]
                def FloatLib.Numerics.Dyadic.isLessFields (leftNegative : Bool) (leftSignificand : ) (leftExponent : ) (rightNegative : Bool) (rightSignificand : ) (rightExponent : ) :

                Executable strict comparison on flattened exact-dyadic fields.

                Instances For
                  @[inline]
                  def FloatLib.Numerics.Dyadic.isLessNonnegativeFields (leftSignificand : ) (leftExponent : ) (rightSignificand : ) (rightExponent : ) :

                  Strict comparison specialized to known-nonnegative scalar fields.

                  Instances For
                    @[inline]
                    def FloatLib.Numerics.Dyadic.isLessPowerOfTwoAtLeading (significand : ) (exponent : ) (leading : ) (power : ) :

                    Test whether a nonnegative dyadic is strictly below an integral power of two when the caller already knows the significand's leading-bit index.

                    Rounding kernels compute this index to normalize their result fields. Reusing it here avoids an alignment shift whose temporary size is proportional to the exponent gap.

                    Instances For
                      @[inline]

                      Executable non-strict comparison, derived from the exact strict comparator.

                      Instances For
                        @[inline]

                        Executable numerical equality for possibly unnormalized dyadics.

                        Structural equality is intentionally unsuitable here because the same number may have several significand/exponent pairs.

                        Instances For
                          @[inline]
                          def FloatLib.Numerics.Dyadic.isLessOrEqualFields (leftNegative : Bool) (leftSignificand : ) (leftExponent : ) (rightNegative : Bool) (rightSignificand : ) (rightExponent : ) :

                          Executable non-strict comparison on flattened exact-dyadic fields.

                          Instances For
                            @[inline]
                            def FloatLib.Numerics.Dyadic.isLessOrEqualNonnegativeFields (leftSignificand : ) (leftExponent : ) (rightSignificand : ) (rightExponent : ) :

                            Non-strict comparison specialized to known-nonnegative scalar fields.

                            Instances For