Function fixedRound

Rounds a floating point number to a specified number of decimal places.
Uses Math.round() internally to avoid floating point precision errors that can occur with direct decimal arithmetic.
For example, 5.2345 rounded to 2 decimal places becomes 5.23.

fixedRound(5.2345, 2); // 5.23
  • Parameters

    • value: number

      the value to round

    • decimals: number

      the number of decimals

    Returns number

    the rounded value