Java Data Type Tutorial - Java BigDecimal.movePointLeft(int n)








Syntax

BigDecimal.movePointLeft(int n) has the following syntax.

public BigDecimal movePointLeft(int n)

Example

In the following code shows how to use BigDecimal.movePointLeft(int n) method.

/*from w  ww . ja  v  a2  s.  com*/

import java.math.BigDecimal;

public class Main {

  public static void main(String[] args) {

    BigDecimal bg1 = new BigDecimal("123.23");
    BigDecimal bg2 = new BigDecimal("12323");

    BigDecimal bg3 = bg1.movePointLeft(3); // 3 points left
    BigDecimal bg4 = bg2.movePointLeft(-2);// 2 points right

    // print bg3, bg4 values
    System.out.println(bg3);
    System.out.println(bg4);
  }
}

The code above generates the following result.