Returns the signum function of the argument; zero if the argument is zero, 1.0 if the argument is greater than zero, -1.0 if the argument is less than zero.
Returns the signum function of the argument; zero if the argument is zero, 1.0f if the argument is greater than zero, -1.0f if the argument is less than zero.

package com.logicbig.example.math;
public class SignumExample {
public static void main(String... args) {
findSignum(4.2);
findSignum(2.5);
findSignum(-8.75);
findSignum(0.0);
findSignum(0.0 / 0);
}
private static void findSignum(double d) {
double result = Math.signum(d);
System.out.printf("Math.signum(%s) = %s%n", d, result);
}
}
Output
Math.signum(4.2) = 1.0
Math.signum(2.5) = 1.0
Math.signum(-8.75) = -1.0
Math.signum(0.0) = 0.0
Math.signum(NaN) = NaN

package com.logicbig.example.math;
public class SignumExample2 {
public static void main(String... args) {
findSignum(1.75f);
findSignum(3.5f);
findSignum(-7.25f);
findSignum(0.0f);
findSignum(0.0f / 0);
}
private static void findSignum(float d) {
float result = Math.signum(d);
System.out.printf("Math.signum(%4s) = %s%n", d, result);
}
}
Output
Math.signum(1.75) = 1.0
Math.signum( 3.5) = 1.0
Math.signum(-7.25) = -1.0
Math.signum( 0.0) = 0.0
Math.signum( NaN) = NaN