Friday, July 24, 2026
HomeLanguagesJavaBigInteger not() Method in Java

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: The method does not take any parameters.

Return Value: The method returns the bitwise-NOT value of a BigInteger with which it is used.

Examples:

Input: value = 2300
Output: -2301
Explanation:
Binary of 2300 = 100011111100
NOT of 100011111100 in signed 2's complement is 1111011100000011
Decimal value = -2301.

Input: value = 567689 
Output: -567690

Below program illustrate the not() method of BigInteger():




/*
*Program Demonstrate not() method of BigInteger 
*/
import java.math.*;
  
public class GFG {
  
    public static void main(String[] args)
    {
  
        // Creates  BigInteger object
        BigInteger biginteger = new BigInteger("2300");
  
        // Call not() method to find ~this
        BigInteger finalvalue = biginteger.not();
        String result = "Result of NOT operation on " + 
        biginteger + " is " + finalvalue;
  
        // Print result
        System.out.println(result);
    }
}


Output:

Result of NOT operation on 2300 is -2301

Reference:https://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html#and(java.math.BigInteger)

RELATED ARTICLES

3 COMMENTS

Most Popular

Dominic
32520 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6902 POSTS0 COMMENTS
Nicole Veronica
12017 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12115 POSTS0 COMMENTS
Shaida Kate Naidoo
7023 POSTS0 COMMENTS
Ted Musemwa
7265 POSTS0 COMMENTS
Thapelo Manthata
6980 POSTS0 COMMENTS
Umr Jansen
6971 POSTS0 COMMENTS