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  o  m


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.





















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