StrictMath.nextAfter(double, double) in Java

StrictMath.nextAfter(double, double): This method is available in java.lang.StrictMath class of Java.

Syntax:

double java.lang.StrictMath.nextAfter(double start, double direction)

This method takes two arguments of type double as its parameters. This method returns the floating-point number adjacent to the first argument in the direction of the second argument. If both arguments compare as equal the second argument is returned.

Parameters: Two parameters are required for this method.

start: starting floating-point value.

direction: value indicating which of start's neighbors or start should be returned.

Returns: The floating-point number adjacent to start in the direction of the direction.

Exceptions: NA

Approach

Java

public class StrictMathnextAfterdouble {
    public static void main(String[] args) {

        double start = 15886.89, direction = 1099;
        System.out.println(StrictMath.nextAfter(start, direction));
    }
}

Output:

15886.889999999998


StrictMath.nextAfter(float, double)

No comments:

Post a Comment