BigDecimal

 正数转为负数,负数转正数:  

negate()

     // 转负数
        BigDecimal bigDecimal = BigDecimal.valueOf(20);
        BigDecimal negate = bigDecimal.negate();
        System.out.println(negate);                      //-20

        // 转正数
        BigDecimal bigDecima2 = BigDecimal.valueOf(-30);
        BigDecimal negate1 = bigDecima2.negate();
        System.out.println(negate1);         //30

 

 
posted @ 2019-02-21 11:14  暗夜云遮日  阅读(1219)  评论(0)    收藏  举报