Rounds a number to a fixed number of decimal places using precision-safe math.
Handles floating-point rounding issues for both positive and negative values (e.g., 1.005 → 1.01, -1.235 → -1.24).
The number to round.
Optional
The number of decimal places to round to.
The rounded number.
1.2.0
toFixedNumber(1.005, 2); // 1.01toFixedNumber(-1.235, 2); // -1.24 Copy
toFixedNumber(1.005, 2); // 1.01toFixedNumber(-1.235, 2); // -1.24
Rounds a number to a fixed number of decimal places using precision-safe math.
Handles floating-point rounding issues for both positive and negative values (e.g., 1.005 → 1.01, -1.235 → -1.24).