Get the sign of the long value

ReturnMethodSummary
static intsignum(long i)Returns the signum function of the long value.

ReturnsMeaning
-1if the specified value is negative;
0if the specified value is zero;
1if the specified value is positive.

public class Main {
  public static void main(String[] args) {
    System.out.println(Long.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.