TorchLean API

FloatLib.Floats.Formats.DecimalInterchange.Arithmetic.Runtime

Decimal rational arithmetic #

Addition, subtraction, multiplication, division, and fused multiply-add compute their finite intermediate values in , then project once. Preferred exponents follow IEEE 754-2019 §5.4.1; signs and exceptional operands follow §§6–7.

NaN propagation chooses the first NaN operand, preserving its sign and payload when the payload fits the destination. Any signaling operand raises invalid. For fma(0, infinity, quietNaN), this implementation raises invalid, one of the two behaviors permitted by §7.2(c). These operations return default exception flags; they do not implement trapping or a mutable floating-point environment.

def FloatLib.Floats.Formats.DecimalInterchange.Datum.finiteValue (negative : Bool) (coefficient : ) (quantum : ) :

Exact value of a finite representation, including either signed zero.

Instances For

    Test the signaling bit only on a NaN.

    Instances For

      Reverse the sign bit without quieting a NaN or changing its payload.

      Instances For

        Quiet NaN propagation. An unrepresentable payload becomes zero.

        Instances For

          Default result of an invalid operation without an input NaN.

          Instances For

            Sign of an exact zero sum. Equal signs survive; cancellation rounds downward to -0.

            Instances For

              Addition, with preferred quantum the smaller operand quantum.

              Instances For

                Subtraction preserves input NaN diagnostics before reversing the second numeric sign.

                Instances For

                  Multiplication, with preferred quantum the sum of the operand quanta.

                  Instances For

                    Division, including the distinction between finite nonzero/zero and infinity/zero. By §5.2, an infinity has quantum exponent +∞; finite/infinity therefore selects the smallest quantum in the signed-zero cohort.

                    Instances For

                      Add a signed infinity to a third operand after a fused product is classified.

                      Instances For

                        Test the invalid zero-times-infinity product, without assigning a value to it.

                        Instances For

                          Fused multiply-add with unbounded intermediate range and exactly one rounding. Neither an overflowing nor an underflowing intermediate product raises a flag.

                          Instances For