The static nextUp()
method returns the floating-point value adjacent to N
(argument value), but in the direction of positive infinity.
static double nextUp(double N)
N
: The initial floating-point value
This function will return the adjacent floating-point value in the direction of positive infinity (+∞).
Here are some special cases regarding nextUp()
:
Double.MIN_VALUE
.The following code illustrates how to use Math.nextUp()
.
import java.lang.*; public class EdPresso { public static void main(String[] args) { // initialize the variables with double values double n1 = 91868.321; double n2 = 786; // printing the next floating-point values directed towards positive infinity System.out.println("Math.nextUp(" + n1 + ")= " + Math.nextUp(n1)); System.out.println("Math.nextUp(" + n2 + ")= " + Math.nextUp(n2)); } }
n1
and n2
are declared and assigned values.n1
and n2
to the Math.nextUp
method.RELATED TAGS
CONTRIBUTOR
View all Courses