Integer.signum() method in Java

The method returns the signum function of the specified int value. Let us now see the syntax.

int signum(int i)

Here is the parameter.

  • i − This is the int value

The return value is -1 if the specified value is negative, 0 if the specified value is zero and 1 if the specified value is positive.

Let us now see an example.


 Live Demo

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));


Returns = 0
Returns = -1
Returns = 1

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 26-Jun-2020


Kickstart Your Career

Get certified by completing the course

Get Started