VOOZH about

URL: https://www.geeksforgeeks.org/java/biginteger-signum-method-in-java/

⇱ BigInteger signum() Method in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

BigInteger signum() Method in Java

Last Updated : 11 Jul, 2025

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

Syntax:  

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.

Examples:  

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

Input: -5482549 
Output: -1


Below program illustrate the signum() method of BigInteger. 


Output: 
BigInteger 2300 is positive and Sing value is 1

 

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

Comment