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








Syntax

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

public BigDecimal movePointRight(int n)

Example

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

/*from ww w. j a va  2  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.movePointRight(3); // 3 places right
    BigDecimal bg4 = bg2.movePointRight(-2);// 2 places left

    System.out.println(bg3);
    System.out.println(bg4);
  }
}

The code above generates the following result.