Java Data Type Tutorial - 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.

/*from  www. j a  va  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.