matician - v2.0.0
    Preparing search index...

    Function sigFig

    • Rounds a number to a specified number of significant figures.

      Significant figures are digits that contribute to a number's precision. This function handles positive, negative, and small/large magnitude numbers.

      Parameters

      • value: number

        The number to round.

      • figures: number

        The number of significant figures to retain (must be ≥ 1).

      Returns number

      The rounded number with the specified significant figures.

      sigFig(1234.567, 3);    // 1230
      sigFig(0.012345, 2); // 0.012
      sigFig(-987.65, 2); // -990
      sigFig(0, 3); // 0