StrictMath.nextAfter(float, double) in Java

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

Syntax:

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

This method takes two arguments one of type float and another 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 a value equivalent to 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 StrictMathnextAfterfloat {
    public static void main(String[] args) {

        float start = 17178.67f;
        double direction = 171.57;
        System.out.println(StrictMath.nextAfter(start, direction));
    }
}

Output:

17178.668


StrictMath.nextAfter(double, double)



No comments:

Post a Comment