TorchLean API

FloatLib.Floats.Formats.DecimalInterchange.Algebraic.Root.Runtime

Decimal integer-degree roots by exact power comparisons #

The integer root brackets the scaled coefficient. Comparing the radicand with the power of the exact midpoint decides nearest rounding, including ties. Precision, degree, and intermediate integers are unbounded.

Negative degrees invert the exact rational radicand before root rounding. Negative nonzero operands require an odd degree. Signed zeros follow the same odd-degree sign rule; a negative degree at zero raises divide-by-zero.

def FloatLib.Floats.Formats.DecimalInterchange.rootScaleShift (precision degree : ℕ) (scaledRadicand : ℚ) :

Decimal grid shift for a root of positive integer degree.

Instances For

    Smallest coefficient grid which fits the exact nonnegative root.

    Instances For

      Integer floor of a nonnegative rational's positive-degree root.

      Instances For

        Exact decision between adjacent coefficients, with directed rounding respecting sign.

        Instances For

          Round a nonnegative root magnitude on the integer grid.

          Instances For
            def FloatLib.Floats.Formats.DecimalInterchange.rootPair (f : Format) (mode : RoundingMode) (negative : Bool) (degree : ℕ) (radicand : ℚ) :

            Rounded root coefficient and quantum, after an exact power-of-ten carry.

            Instances For
              def FloatLib.Floats.Formats.DecimalInterchange.rootMagnitude (f : Format) (mode : RoundingMode) (negative : Bool) (degree : ℕ) (radicand : ℚ) (preferred : ℤ) :

              Round a positive-degree root of a nonnegative rational magnitude. Only the final root can raise overflow or underflow. Exact results retain the preferred cohort, and inexactness is decided by an exact power equality.

              Instances For

                Integer-degree root with one final rounding. Degree zero is invalid for every operand, including NaNs. Other degrees use the usual decimal NaN propagation. For an exact finite result, the preferred quantum is the floor of the signed operand quantum divided by the positive degree magnitude.

                Instances For