Java Data Type Tutorial - Java Math.signum(float f)








Syntax

Math.signum(float f) has the following syntax.

public static float signum(float f)

Example

In the following code shows how to use Math.signum(float f) method.

public class Main {
//w w w . j av a  2 s .c  om
   public static void main(String[] args) {

      float x = 12.34f;
      float y = -4f;

      // call signum for both floats and print the result
      System.out.println("Math.signum(" + x + ")=" + Math.signum(x));
      System.out.println("Math.signum(" + y + ")=" + Math.signum(y));

   }
}

The code above generates the following result.