Java BigInteger modInverse() method20 Mar 2025 | 2 min read The modInverse() method of Java BigInteger class is used to find the modulus of the inverse of this BigInteger value. This method returns a BigInteger whose value is inverse of this BigInteger mod parameter value. Syntax:Parameter:m- the modulus. Returns:The method returns (this-1 mod m). Exception:ArithmeticException - if(m ≤ 0). Note: This method throws an ArithmeticException if the inverse of this BigInteger does not exist (that is, this BigInteger is not relatively prime to parameter value).Example 1Output: 13^-1 % 5 is 2 Example 2Output: -13^-1 % 5 is 3 Example 3Output: java.lang.ArithmeticException: BigInteger: modulus not positive Example 4Output: java.lang.ArithmeticException: BigInteger: modulus not positive Next TopicJava BigInteger |
Java BigInteger Method The method of Java BigInteger classreturns a BigInteger which corresponds to the result of clearing a bit designated by the method argument n. Syntax: public BigInteger clearBit(int n) Parameter: n-index of bit to clear entered by user Returns: This method returns a bigInteger of value,(this &~(1<<n)). Throws: ArithmeticException -...
1 min read
Java BigInteger method The method of Java BigInteger class is used to convert this BigInteger to a long.This conversion is similar to the narrowing primitive conversion from long to int. Narrowing Primitive Conversion: According to The Java Language Specification, it is defined as ifthisBigInteger has too...
2 min read
Java BigInteger Method The method of Java BigInteger class is used to set the bit position. This method returns a BigInteger whose value is equivalent to this BigInteger with the designated bit set. Syntax: public BigInteger setBit(int n) Parameter: n- Index of the bit to set entered by...
2 min read
Java BigInteger method Themethod of Java BigInteger class is used tosubtracttwo BigInteger values.This method performs subtraction of this BigInteger and the method argument.This method returns a BigInteger whose value is (this - val). Syntax: public BigInteger subtract(BigInteger val) Parameter: val - Avalue to be subtracted from this BigInteger entered...
1 min read
Java BigInteger method The method of Java BigInteger class is used to find the binary representation of this BigInteger in the form of byte array. A byte array contains the minimum number of bytes required to represent this BigInteger, including at least one sign...
3 min read
Java BigInteger method The method of Java BigInteger class is used to get the position of the rightmost set bit of this BigInteger. This method returns an integer whose value is the total number of reset bits (0's) to the right of the rightmost...
2 min read
Java BigInteger method The method of Java BigInteger class is used to check whether a BigInteger value is positive, negative or zero. This method returns one of the following values depending on the following conditions : This method returns 1 when this BigInteger is positive. This...
1 min read
Java BigInteger method The method of Java BigInteger class is used to divide two BigInteger values.This method returns a BigInteger whose value is (this / val). Syntax: public BigInteger divide(BigIntegerval) Returns: This method returns a BigInteger whose value is (this / val) Throws: ArithmeticException- if val is zero. Note: Since the...
1 min read
Java BigInteger method The method of Java BigInteger class is used to flip a particular bit position in a BigInteger.This method returns the BigInteger after flipping its bit at index n. Syntax: public BigInteger flipBit(int n) Parameter: n- The position of the bit to be flipped Return value This method...
1 min read
Java BigInteger Method The method of Java BigInteger class is used to shift the bits to the left by n times (shift distance). This method returns a BigInteger whose value is (this<<n). This method Computes floor (this * 2n). Syntax: public BigInteger shiftLeft(int n) Parameter: n- shift distance,...
2 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India