Shift left in a BigInteger in Java

To shift left in a BigInteger, use the shiftLeft() method.

The java.math.BigInteger.shiftLeft(int n) returns a BigInteger whose value is (this << n). The shift distance, n, may be negative, in which case this method performs a right shift. It computes floor(this * 2n).


 Live Demo

import java.math.*;
public class Demo {
   public static void main(String[] args) {
      BigInteger one;
      one = new BigInteger("25");
      one = one.shiftLeft(3);
      System.out.println("Result: " +one);


Result: 200
Samual Sam
Samual Sam

Learning faster. Every day.