index/functions/decimalRoundingUp.md
decimalRoundingUp(
value,decimals):BigNumber
Round decimal up to specified precision (ceiling rounding)
Always rounds UP to the specified decimal places. This ensures system accuracy and prevents shortchanging calculations (e.g., fee calculations always round up to protect the fee recipient).
Consolidates 3 occurrences of Math.ceil with decimal precision patterns.
big number
Parameters
| Parameter | Type | Description |
|---|---|---|
value | string | number | BigNumber | Value to round (string, number, or BigNumber) |
decimals | number | Number of decimal places to preserve |
big number
Returns
BigNumber
Rounded value as BigNumber
big number
Throws
Error if decimals is negative
Example
// Fee calculations that always round up
const fee = decimalRoundingUp('1.234', 2); // 1.24 (rounds up from 1.23)
// Preserve more decimals
const precise = decimalRoundingUp('1.23456', 4); // 1.2346
// Integer rounding
const integer = decimalRoundingUp('1.1', 0); // 2 (rounds up to next integer)
// Very small values
const tiny = decimalRoundingUp('0.00001', 4); // 0.0001