Java BigInteger andNot() Method

20 Mar 2025 | 1 min read

The andNot() method of Java BigInteger classreturns the bitwise AND of this BigInteger and the bitwise negation of the given BigInteger as a new BigInteger. Calling this method is equivalent to calling and (val.not()).

Syntax:

Parameter:

val - Value to be complemented and AND'ed with this BigInteger.

Returns:

This method returns a BigInteger object of value, this & ~val.

Note:This method returns a negative BigInteger if and only if this is negative and val is positive.

Example 1

Output:

Result of andNot operation is 3

Example 2

Output:

Result of andNot operation is -7
 
Next TopicJava BigInteger
 
 




close