Java Data Type Tutorial - Java BigInteger.shiftLeft(int n)








Syntax

BigInteger.shiftLeft(int n) has the following syntax.

public BigInteger shiftLeft(int n)

Example

In the following code shows how to use BigInteger.shiftLeft(int n) method.

/*from   www  . j ava  2 s .  c  o  m*/
import java.math.BigInteger;

public class Main {

  public static void main(String[] args) {

    BigInteger bi1 = new BigInteger("10");

    // perform leftshift operation on bi1 using 2 and -2
    BigInteger bi2 = bi1.shiftLeft(2);
    BigInteger bi3 = bi1.shiftLeft(-2);

    System.out.println(bi2);
    System.out.println(bi3);
  }
}

The code above generates the following result.