Java Integer signum() Method

The signum() method of Java Integer class returns the signum function of the specified int value in the method argument. The signum function can be computed as:

  1. -1, if the specified number is negative.
  2. 0, if the specified number is zero.
  3. 1, if the specified number is positive.

Syntax:

Following is the declaration of signum() method:

Parameter:

DataTypeParameterDescriptionRequired/Optional
intiInteger value whose signum is to be computed.Required

Returns:

The signum() method returns the signum function of the specified int value in the method argument.

Exceptions:

NA

Compatibility Version:

Java 1.5 and above

Example 1

Output:

Result: 1
Result: -1
Result: 0

Example 2

Output:

Enter Positive Value: 4565
Result: 1
Enter Negative Value: -432
Result: -1
Enter Zero Value: 000
Result: 0

Example 3

Output:

Output: NaN
Output: 0.0
Output: 0.0