Java Utililty Methods Number Sign

List of utility methods to do Number Sign

Description

The list of methods to do Number Sign are organized into topic(s).

Method

intsignum(byte[] value)
signum
if (value.length > 0) {
    if (value[0] < 0) {
        return -1;
    for (int i = 0; i < value.length; i++) {
        if (value[i] != 0) {
            return 1;
return 0;
doublesignum(Double d)
Signum.
return Math.signum(d);
intsignum(double value)
Returns the signum of the long value, i.e.
return (int) Math.signum(value);
intsignum(double z)
Returns sign of double number.
return (z < 0) ? -1 : 1;
intsignum(final double x)
Returns the signum function of the specified double value.
if (x < 0) {
    return -1;
if (x > 0) {
    return 1;
return 0;
intsignum(final int a)
signum
return a < 0 ? -1 : a == 0 ? 0 : 1;
intsignum(final int i)
signum function.
if (i < 0) {
    return -1;
} else if (i > 0) {
    return 1;
} else {
    return 0;
intsignum(final int n)
Returns the signum function of the argument; zero if the argument is zero, 1 if the argument is greater than zero, -1 if the argument is less than zero.
if (n > 0) {
    return 1;
} else if (n < 0) {
    return -1;
} else {
    return 0;
intsignum(final int value)
signum
if (value > 0) {
    return 1;
} else if (value < 0) {
    return -1;
} else {
    return 0;
floatsignum(float f)
Returns -1.0, 0.0, or 1.0 as the given float is negative, zero, or positive, respectively.
if (f == 0.0f)
    return 0.0f;
return f < 0.0f ? -1.0f : 1.0f;