Home » Java Math.signum() Method with Examples

Java Math.signum() Method with Examples

by Online Tutorials Library

Java Math.signum() method

The java.lang.Math.signum () is used to find the sign of a given value.

Syntax

Parameter

Return

  • If the argument is positive or negative Zero, this method will return Zero.
  • If the argument is positive value, this method will return Positive 1.
  • If the argument is Negative value, this method will return Negative 1.
  • If the argument is NaN, this method will return NaN.

Example 1

Test it Now

Output:

1.0  

Example 2

Test it Now

Output:

-1.0  

Example 3

Test it Now

Output:

0.0  

Example 4

Test it Now

Output:

NaN  

Next TopicJava Math

You may also like