Javatpoint Logo
Javatpoint Logo

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:

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

Test it Now

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

Test it Now

Output:

Output: NaN
Output: 0.0
Output: 0.0

Next Topicsum() Method




Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA