Returns the rounded BigDecimal value.
BigDecimal.round(value, rounding)
value
The BigDecimal value.
rounding
The rounding object must contain the following properties:
roundingMode
A string specifying the rounding mode: "floor", "ceiling", "down", "up", "half-even", "half-up".
maximumSignificantDigits optional
The number of significant digits (must be >= 1).
maximumFractionDigits optional
The number of digits after the decimal point (must be >= 0).
Either maximumSignificantDigits or maximumFractionDigits must be present.
A new BigDecimal.
BigDecimal.round(1.2345m, { roundingMode: 'half-up', maximumFractionDigits: 0 })
1
BigDecimal.round(1.2345m, { roundingMode: 'half-up', maximumFractionDigits: 3 })
1.235
BigDecimal.round(1.2345m, { roundingMode: 'down', maximumFractionDigits: 3 })
1.234
BigDecimal.round(12345m, { roundingMode: 'half-up', maximumSignificantDigits: 1 })
10000