BigInteger signum() Method in Java

prerequisite : BigInteger Basics
The java.math.BigInteger.signum() method helps us to identify whether a BigInteger is positive or zero or negative. It returns one of the following values depending on the following conditions:

  • returns -1 when number is negative
  • returns 0 when number is zero
  • returns +1 when number is positive


public int signum()

Parameters: The method does not take any parameters.

Return Value: The method returns -1, 0 or 1 as the value of this BigInteger when they are negative, zero or positive respectively.


Input: 2300 
Output: 1
Explanation: 2300 is postive number 
so the method returns 1

Input: -5482549 
Output: -1

Below program illustrate the signum() method of BigInteger.





// Program Demonstrate signum() method of BigInteger 
import java.math.*;
public class GFG {
    public static void main(String[] args)
        // Creating BigInteger object
        BigInteger biginteger = new BigInteger("2300");
        // Call signum() method on bigInteger
        // store the return value as int
        int sigvalue = biginteger.signum();
        // Depending upon sign value find sign of biginteger
        String sign = null;
        if (sigvalue == 0)
            sign = "zero";
        else if (sigvalue == 1)
            sign = "positive";
            sign = "negative";
        // Defining result
        String result = "BigInteger " + biginteger + " is "
        sign + " and Sing value is " + sigvalue;
        // Print result



BigInteger 2300 is positive and Sing value is 1


Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.