Returns the product of two BigDecimal values.
You can also use the / operator on BigDecimal values.
BigDecimal.div(a, b, rounding?)
a
The dividend BigDecimal.
b
The divisor BigDecimal.
rounding optional
If present, 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.
Throws a RangeError exception in case of division by zero or if the result cannot be represented with infinite precision and no rounding object is present.
10m / 4m
2.5
BigDecimal.div(10m, 4m)
2.5
BigDecimal.div(10m, 6m)
RangeError: invalid operation
BigDecimal.div(10m, 6m, { roundingMode: "half-up", maximumFractionDigits: 5 })
1.66667
BigDecimal.div(10m, 0m)
RangeError: division by zero