BigInteger shiftLeft() Method in Java Last Updated : 04 Dec, 2018 Comments Improve Suggest changes Like Article Like Report The java.math.BigInteger.shiftLeft(int n) 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.shiftLeft() method will moves each digit in a number's binary representation left by n times and the last bit in the direction of the shift is replaced by 0. This ShiftLeft() method Computes floor(this * 2^n). Syntax: public BigInteger shiftLeft(int n) Parameters: The method takes one parameter n of integer type, which refers to the shift distance, in bits. Return Value: The method returns the BigInteger after shifting the bits to left by n times. Exceptions: The method might throw an ArithmeticException if the shift distance is Integer.MIN_VALUE. Examples: Input: value = 2300, shift distance = 3 Output: 18400 Explanation: Binary Representation of 2300 = 100011111100 shift distance = 3 after shifting 100011111100 left 3 times then Binary Representation becomes 100011111100000 and Decimal equivalent of 100011111100000 is 18400. Another way of expressing the same can be 2300*(2^3)=18400 Input: value = 35000, index = 5 Output: 1120000 Below program illustrate shiftLeft(index) method of BigInteger. Java // Program to demonstrate shiftLeft() method of BigInteger import java.math.*; public class GFG { public static void main(String[] args) { // Creating BigInteger object BigInteger biginteger = new BigInteger("2300"); // Creating a int i for Shift Distance int i = 3; // Call shiftLeft() method on bigInteger at index i // store the return value as BigInteger BigInteger changedvalue = biginteger.shiftLeft(i); String result = "After applying ShiftLeft by Shift Distance " + i + " on " + biginteger + " New Value is " + changedvalue; // Printing result System.out.println(result); } } Output: After applying ShiftLeft by Shift Distance 3 on 2300 New Value is 18400 Reference: https://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html#shiftLeft(int) Comment More infoAdvertise with us Next Article BigInteger shiftLeft() Method in Java A AmanSingh2210 Follow Improve Article Tags : Java Java-Functions java-math Java-BigInteger Java-math-package +1 More Practice Tags : JavaJava-BigInteger Similar Reads BigInteger shiftRight() Method in Java prerequisite : BigInteger Basics The java.math.BigInteger.shiftRight(int n) method returns a BigInteger whose value is (this >> n). The shift distance, n, may be negative, in which case this method performs a left shift. The shiftRight() method will move each digit in a number's binary represe 2 min read BigInteger setBit() Method in Java The java.math.BigInteger.setbit(index) method returns a Big-integer whose value is equivalent to this Big-integer with the designated bit set. The method computes (this | (1<<n)). The bit at index n of binary representation of Big-integer will be set means converted to 1. Syntax: public BigInt 2 min read BigInteger valueOf() Method in Java The java.math.BigInteger.valueOf(long value) method returns a BigInteger whose value is equal to value of long passed as parameter. This method is static method so It is not necessary to create object of BigInteger class to use this method.we can call this function by BigInteger.valueOf(long value) 2 min read BigInteger not() Method in Java The java.math.BigInteger.not() method is used to find the bitwise-NOT of a BigInteger. This method returns a negative value if and only if this BigInteger is non-negative. The BigInteger.not() method apply bitwise Not operation upon the current bigInteger. Syntax: public BigInteger not() Parameters: 1 min read BigInteger xor() Method in Java Prerequisite: BigInteger Basics The xor(BigInteger val) method returns bitwise-XOR of two bigIntegers. This method returns a negative BigInteger if and only if exactly one of the current bigInteger and the bigInteger passed in parameter id negative. The xor() method of BigInteger class apply bitwise 2 min read Like