Java Data Type Tutorial - Java Math.nextUp(double d)








Syntax

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

public static double nextUp(double d)

Example

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

/*from  w w  w .  j ava 2  s. c  om*/


public class Main {

   public static void main(String[] args) {
      double x = 123456.7;
      double y = -123.45;


      // print the next floating numbers towards positive infinity
      System.out.println("Math.nextUp(" + x + ")=" + Math.nextUp(x));
      System.out.println("Math.nextUp(" + y + ")=" + Math.nextUp(y));

   }
}

The code above generates the following result.