Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
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).
Example
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);
}
}
Output
Result: 200
Advertisements
