English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Integer.signum() Method in Java

This method returns the signum function of the specified int value. Now let's see the syntax.

int signum(int i)

This is the parameter.

  • i-This is an int value

If the specified value is negative, it returns the value-1;If the specified value is zero, it returns 0; if the specified value is positive, it returns1.

Now let's look at an example.

Example

public class Demo {
   public static void main(String []args) {
      System.out.println("Returns = "+Integer.signum(0));
      System.out.println("Returns = "+Integer.signum(-99));
      System.out.println("Returns = "+Integer.signum(678));
   }
}

Output Result

Returns = 0
Returns = -1
Returns = 1