One - One Code All

Blog Content

Java.math.BigDecimal.negate()方法实例

Java   2013-09-18 21:56:04

java.math.BigDecimal.negate() 返回一个BigDecimal,其值是(-this),其标度是this.scale()。
声明
以下是java.math.BigDecimal.negate()方法的声明

public BigDecimal negate()

参数
    NA

返回值
此方法返回的对象的负值,即: -this

import java.math.*;

public class BigDecimalDemo {

   public static void main(String[] args) {

      // create 2 BigDecimal objects
      BigDecimal bg1, bg2;

      // assign value to bg1
      bg1 = new BigDecimal("40.1264");

      // assign negate value of bg1 to bg2
      bg2 = bg1.negate();

      String str = "Negated value of " + bg1 + " is "+ bg2;

      // print bg1 and bg2 values
      System.out.println( str );
   }
}



上一篇:python求两个时间的时间差
下一篇:线性代数java包,Jama的常用方法

The minute you think of giving up, think of the reason why you held on so long.