TorchLean API

FloatLib.Floats.Formats.DecimalInterchange.Formatting.Precision

Selecting decimal output precision #

IEEE 754 §5.12.2 distinguishes preserving the source quantum from requesting a number of significant digits. Precision makes this choice explicit. Requested precision has no format-width cap: the coefficient is rounded once on the requested decimal grid, and extra requested digits are supplied by exact zeros. The text exponent is an unbounded integer, so output has no exponent overflow.

Zero at precision p is written with quantum 1-p. Special values keep their exact spellings and fields. Only inexact can be raised during finite output.

@[reducible, inline]

Preserving the original quantum and requesting a digit count are separate operations.

Instances For
    @[reducible, inline]

    Correctly rounded significant-digit output, with an unbounded requested precision.

    Instances For

      The external string together with the conversion's IEEE status flags.

      • text : String

        The generated external decimal character sequence.

      • status : Status

        Exceptions raised by this conversion; output rounding can raise only inexact.

      Instances For

        Format a datum either exactly or to a requested significant-digit count. The inexact flag records numerical rounding, rather than a change of quantum.

        Instances For