Home >>Java Math Methods >Java Math.signum() method
Java Math.signum() method in Java Math is used for finding the sign of a value given.
Syntax:
public static double signum(double x) public static float signum(float x)
x = This parameter is used for a floating-point value whose signum is to be returned
It is used to returns the signum function of an argument
Java Math.signum method Example 1
public class MyClass
{
public static void main(String[] args)
{
double x= 23.5;
System.out.println(Math.signum(x));
}
}
Java Math.signum method Example 2
public class MyClass
{
public static void main(String[] args)
{
double x= -15.8;
System.out.println(Math.signum(x));
}
}