Hyperlinkv0.8.0-beta.28

BigDecimal

BigDecimal.ceilconsteffect/BigDecimal.ts:1870
(scale: number): (self: BigDecimal) => BigDecimal
(self: BigDecimal, scale?: number): BigDecimal

Computes the ceiling of a BigDecimal at the given scale.

When to use

Use to round a decimal toward positive infinity at a requested scale.

Details

The default scale is 0. Positive scales keep digits to the right of the decimal point, and negative scales round positions to the left of the decimal point.

export const ceil: {
  (scale: number): (self: BigDecimal) => BigDecimal
  (self: BigDecimal, scale?: number): BigDecimal
} = dual(isBigDecimalArgs, (self: BigDecimal, scale: number = 0): BigDecimal => {
  const truncated = truncate(self, scale)

  if (isPositive(self) && isLessThan(truncated, self)) {
    return sum(truncated, make(bigint1, scale))
  }

  return truncated
})
Referenced by 2 symbols