Java Math.ulp(double d)

Syntax

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

public static double ulp(double d)

Example

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


//ww w  .  j  a  v  a  2 s  .  c  o  m

public class Main {

   public static void main(String[] args) {

      double x = 123.456;
      double y = 123.1;

      // print the ulp of these doubles
      System.out.println("Math.ulp(" + x + ")=" + Math.ulp(x));
      System.out.println("Math.ulp(" + y + ")=" + Math.ulp(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