Get the sign of an Integer

ReturnMethodSummary
static intsignum(int i)Returns the signum.

signum(int i) Returns

ValueMeaning
-1if i is negative;
0if i is zero;
1if i is positive.

public class Main {
  public static void main(String[] args) {

    System.out.println(Integer.signum(10));
  }
}

The output:


1
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.