日期:2014-05-20 浏览次数:23202 次
BigDecimal decimal = new BigDecimal(123); decimal = decimal.multiply(new BigDecimal(-1)); System.out.println(decimal);
------解决方案--------------------
不看文档
public BigDecimal negate()
Returns a BigDecimal whose value is (-this), and whose scale is this.scale().
public BigDecimal negate(MathContext mc)
Returns a BigDecimal whose value is (-this), with rounding according to the context settings.
Parameters: mc - the context to use.
Returns: -this, rounded as necessary.
Throws: ArithmeticException - if the result is inexact but the rounding mode is UNNECESSARY.