Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

BigInteger not() Method in Java

  • Last Updated : 04 Dec, 2018

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.


Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

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.


Input: value = 2300
Output: -2301
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
Result of NOT operation on 2300 is -2301


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!