@jiminp/tooltool
    Preparing search index...

    Function formatSignedInt

    • Formats a number with an explicit sign prefix (+, -, or ± for zero).

      Parameters

      • n: number

        The number to format.

      • Optionalmin_len: number

        Minimum UTF-16 length of the numeric part, excluding the sign.

      • Optionalfill_string: string

        Padding string (default: ' ').

      Returns string

      The formatted string with sign prefix.

      Uses the number's string representation without rounding or truncating it to an integer. Padding is applied before the numeric part but after the sign; an empty padding string adds nothing. Both positive and negative zero use ±.

      formatSignedInt(42);        // "+42"
      formatSignedInt(-5); // "-5"
      formatSignedInt(0); // "±0"
      formatSignedInt(5, 3, '0'); // "+005"