Java Math.signum(double d)

Syntax

Math.signum(double d) has the following syntax.

public static double signum(double d)

Example

In the following code shows how to use Math.signum(double d) method.


//from   www  .  j a  v a  2s .co m
public class Main {

   public static void main(String[] args) {

      double x = 12.34;
      double y = -4;

      // call signum for both doubles 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.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable