Method Divide
Divide(BigDecimal, BigDecimal, int, RoundingMode)
Performs a division operation using the specified maximum extended precision.
Declaration
public static BigDecimal Divide(BigDecimal dividend, BigDecimal divisor, int maxExtendedPrecision, RoundingMode mode = RoundingMode.MidpointToEven)
Parameters
| Type | Name | Description |
|---|---|---|
| BigDecimal | dividend | The dividend of the division operation. |
| BigDecimal | divisor | The divisor of the division operation. |
| int | maxExtendedPrecision | The precision used for a result that is not exact if the dividend and divisor precisions are lower. The result can have one more significant digit than the precision used, see the remarks. |
| RoundingMode | mode | The rounding mode to use. |
Returns
| Type | Description |
|---|---|
| BigDecimal |
Remarks
With P being the largest of maxExtendedPrecision, the dividend precision and the divisor precision, a result that is not
exact is rounded to P + 1 significant digits if the significant digits of the dividend are greater than or equal to those of the divisor (compared
digit by digit from the first significant digit, ignoring the decimal point position), and to P significant digits otherwise. For example, with
maxExtendedPrecision set to 5, 1 / 3 is 0.33333 and 2 / 3 is 0.66667, but 5 / 3 is 1.66667. Trailing zeros of the rounded
result are removed.