@leanchuck/core - v0.1.1
    Preparing search index...

    Function roundTo

    • Rounds a number to a fixed number of decimal places.

      Uses toFixed + parseFloat rather than Math.round(x * 10 ** n) / 10 ** n because it is consistently fast across JS engines and avoids most floating point drift for the magnitudes used in analytics.

      Parameters

      • value: number

        The number to round.

      • places: number = 4

        Decimal places to keep. Defaults to 4.

      Returns number

      The rounded number.

      roundTo(0.123456);      // 0.1235
      roundTo(0.123456, 2); // 0.12