Integer signum()
Java Integer signum() Method
Last Updated : 17 Mar 2025
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, if the specified number is negative.
- 0, if the specified number is zero.
- 1, if the specified number is positive.
Syntax:
Following is the declaration of signum() method:
Parameter:
| DataType | Parameter | Description | Required/Optional |
|---|---|---|---|
| int | i | Integer 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
Next TopicJava-integer-sum-method