To divide BigDecimal b1 by b2 and assign the result to b1, you write _________.
时间: 2024-03-24 18:40:30 浏览: 141
BigDecimal的计算
To divide BigDecimal `b1` by `b2` and assign the result to `b1`, you write:
```
b1 = b1.divide(b2);
```
This code uses the `divide()` method of the `BigDecimal` class to divide `b1` by `b2`, and then assigns the result back to `b1`. Note that the `divide()` method returns a new `BigDecimal` object that represents the result of the division, so you need to assign it back to `b1` to update its value. Also note that the `divide()` method uses rounding to determine the final result, so you may need to specify a `MathContext` object to control the rounding behavior.
阅读全文