展开全部
简单数值类型才支持+-*/
BigDecimal是对象e68a84e8a2ad3231313335323631343130323136353331333431363061类型,要通过相应的方法来计算
for example
Java code
BigDecimal decimal = new BigDecimal(123);
decimal = decimal.multiply(new BigDecimal(-1));
System.out.println(decimal)。
扩展资料:
BigDecimail 转负数negate()
new BigDecimail().negate() 返回负数
源码:
/** * Returns a {@code BigDecimal} whose value is {@code (-this)},* and whose scale is {@code this.scale()}.
*
* @return {@code -this}.
*/
if (intCompact == INFLATED) {
return new BigDecimal(intVal.negate(), INFLATED, scale, precision);
} else { return valueOf(-intCompact, scale, precision); } }