Java Number Sign signum(final int a)

Here you can find the source of signum(final int a)

Description

signum

License

Open Source License

Return

1 if the specified value is > 0, 0 if it is 0, -1 otherwise.

Declaration

public static int signum(final int a) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from  ww  w. j a  va2 s. c  om
     * @return 1 if the specified value is > 0, 0 if it is 0, -1 otherwise.
     */
    public static int signum(final int a) {
        return a < 0 ? -1 : a == 0 ? 0 : 1;
    }

    /**
     * @return 1 if the specified value is > 0, 0 if it is 0, -1 otherwise.
     */
    public static int signum(final long a) {
        return a < 0 ? -1 : a == 0 ? 0 : 1;
    }
}

Related

  1. signum(byte[] value)
  2. signum(Double d)
  3. signum(double value)
  4. signum(double z)
  5. signum(final double x)
  6. signum(final int i)
  7. signum(final int n)
  8. signum(final int value)
  9. signum(float f)