Java Math signum() Method

The signum() method of Java Math class returns the signum function of the value.

Syntax:

  1. public static double signum(double d)
  2. public static float signum (float d)

Parameters:

The parameter ‘d’ represents the floating-point value whose signum is to be determined.

Return Value:

The signum() method returns the signum function of ‘d’.

  • It returns zero with same sign as argument, if the argument passed is zero.
  • It returns 1.0, if the argument is greater than 0.
  • It returns -1.0, if the argument is less than 0.
  • It returns NaN. If the argument is NaN.

Example 1:

Output:

Example 2:

Output:

Example 3:

Output:

Example 4:

Output: