Java Math BigDecimal.movePointLeft() 方法


Java Math BigDecimal.movePointLeft() 方法

package com.codingdict;



import java.math.*;



public class BigDecimalDemo {



   public static void main(String[] args) {



      // create 4 BigDecimal objects

      BigDecimal bg1, bg2, bg3, bg4;



      bg1 = new BigDecimal("123.23");

      bg2 = new BigDecimal("12323");



      bg3 = bg1.movePointLeft(3); // 3 points left

      bg4 = bg2.movePointLeft(-2);// 2 points right



      String str1 = "After moving the Decimal point " + bg1 + " is " + bg3;

      String str2 = "After moving the Decimal point " + bg2 + " is " + bg4;



      // print bg3, bg4 values

      System.out.println( str1 );

      System.out.println( str2 );

   }

}