TorchLean API

FloatLib.Floats.Formats.P3109.Arithmetic.Instances

Public P3109 arithmetic capabilities #

Every valid P3109 descriptor supplies addition, subtraction, multiplication, division, square root, and fused multiply-add through common ExecFloat dispatch. Each has one exact arithmetic kernel followed by the report projection. The caller's backend planning policy is kept.

Context-free operations use FloatLib's nearest-even, no-saturation projection policy. Other rounding modes, stochastic random words, saturation, and mixed-format destinations are available through the mode, saturation, and target options of ExecFloat.P3109.add and its siblings. These operations neither raise nor synthesize IEEE exception flags.

Literals round once from their exact rational value with the same default policy, and == is numerical equality: NaN compares unequal to every value, itself included.

The rational real-embedding and decoding proofs are in Arithmetic.Proof. The irrational-root refinement and decoding proofs are in Arithmetic.Sqrt.Proof.

Planner metadata for the exact arithmetic implementation.

The storage class describes the encoded operand, not an intermediate-size bound. Exact rational arithmetic can allocate integers whose sizes depend on the descriptor's exponent range.

Instances For
    @[instance_reducible, always_inline]

    Package the single exact kernel without changing the caller's planning policy.

    Instances For
      @[instance_reducible]

      Report-default negation, including projection of unsigned results.

      @[instance_reducible]
      instance FloatLib.Floats.ExecFloat.P3109.instOfNat {format : Formats.P3109.Format} (value : ℕ) :
      OfNat (P3109 format) value

      A natural literal rounds once, nearest-even with no saturation request.

      @[instance_reducible]

      A decimal or scientific literal rounds once from its exact rational value.

      @[instance_reducible]

      == is numerical equality, so NaN compares unequal to every value, itself included.

      @[instance_reducible, always_inline]

      Exact addition with one nearest-even report projection.

      @[instance_reducible, always_inline]

      Exact subtraction with one nearest-even report projection.

      @[instance_reducible, always_inline]

      Exact multiplication with one nearest-even report projection.

      @[instance_reducible, always_inline]

      Exact division with the report's NaN result for every zero denominator.

      @[instance_reducible, always_inline]

      Square root rounded by exact comparisons with the irrational result.

      @[instance_reducible, always_inline]

      Fused multiply-add with no rounded or saturated intermediate product.