shiftLeft(): This method is available in java.math.BigInteger class of Java.
Syntax:
BigInteger java.math.BigInteger.shiftLeft(int n)
This method takes one argument of type int as its parameter. This method returns a BigInteger whose value is (this << n). The shift distance, n, may be negative, in which case this method performs a right shift.(Computes floor(this * 2n).).
Parameters: One parameter is required for this method.
n: shift distance, in bits.
Returns: this << n.
For Example:
BigInteger bigInteger = new BigInteger("1234")
int n = 3
bigInteger.shiftLeft(n) = > It returns 9872.
Approach
Java
import java.math.BigInteger;public class BigIntegershiftLeft {public static void main(String[] args) {BigInteger bigInteger = new BigInteger("1234");int n = 3;System.out.println(bigInteger.shiftLeft(n));}}
Output:
9872
No comments:
Post a Comment