StrictMath.signum(double) in Java

StrictMath.signum(double): This method is available in java.lang.StrictMath class of Java.

Syntax:

double java.lang.StrictMath.signum(double d)

This method takes one argument of type double as its parameter. This method 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.

Note:

1. If the argument is NaN, then the result is NaN.

2. If the argument is positive zero or negative zero, then the result is the same as the argument.

Parameters: One parameter is required for this method.

d: the floating-point value whose signum is to be returned.

Returns: the signum function of the argument.

Exceptions: NA

Approach

Java

public class StrictMathsignumdouble {
    public static void main(String[] args) {

        double d = 167;
        System.out.println(StrictMath.signum(d));
    }
}

Output:

1.0


StrictMath.signum(float)


No comments:

Post a Comment