Run results for: Decimal Rounding - Exponential notation vs Number.EPSILON vs Double rounding vs Double rounding v2
A benchmark for solutions that provide accurate decimal rounding, flooring, and ceiling to a specific number of decimal places. These solutions treat floats more like decimals by fixing the binary rounding issues to avoid unexpected results.
Solution 1: converting the number to a string in the exponential notation (e.g., num + "e" + decimalPlaces).
Solution 2: purely mathematical (Number.EPSILON)
Solution 3: double rounding. This solution uses the Number.prototype.toPrecision() method to strip the floating-point round-off errors.
Solution 4: double rounding v2. This solution is just like Solution 3, however it uses a custom toPrecision() function.