StaticceilComputes the smallest integer greater than or equal to a number, resolved to a specified number of decimal places.
The number to evaluate.
The number of decimal places to resolve to. Defaults to 0.
The ceiling value of the number resolved to the specified decimal places.
StaticfloorComputes the largest integer less than or equal to a number, resolved to a specified number of decimal places.
The number to evaluate.
The number of decimal places to resolve to.
The floored value of the number resolved to the specified decimal places.
StaticroundRounds a number to a specified number of decimal places.
The number to round.
The number of decimal places to round to. Defaults to 0. Can be negative to round to tens, hundreds, etc.
The rounded number.
StatictoFormats a number using fixed-point notation with accurate rounding.
The number to format.
The number of digits to appear after the decimal point.
A string representation of the number in fixed-point notation.
StatictruncTruncates a number to a specified number of decimal places, removing any fractional digits beyond that precision.
The number to truncate.
The number of decimal places to truncate to.
The truncated number.
A utility class for handling decimal precision arithmetic.
This helper offers more accurate results for rounding, ceiling, flooring, truncation, and fixed-point representation than standard JavaScript
Mathfunctions, which can suffer from binary floating-point precision issues.See
Stack Overflow reference - Solution 2
Example
Basic usage of DecimalPrecision methods