nextDown(double num)
The nextDown(double num) is the inbuilt method of StrictMath class in Java which is used to get the floating point value that is adjacent to num in the direction of negative infinity. The result is NaN when argument is a NaN. It returns negative infinity when the num is negative infinity. The result is Double.MIN_VALUE when the argument is zero. The nextDown() method is equivalent to nextAfter(num, Double.NEGATIVE_INFINITY) but nextDown() runs faster than its equivalent nextAfter call.Â
Syntax:Â
public static double nextDown(double num)
Parameters: The method accepts one parameter num of double type which is the starting floating point value.
Return Value: The method returns the adjacent floating-point value closer to negative infinity.
Examples :Â
Input: num = 7.16 Output: 7.159999999999999
Below programs illustrate the nextDown() Method:
Program 1:Â
Java
| // Java program to illustrate the// Java.lang.StrictMath.nextDown() Method  importjava.lang.*;  publicclassGeeks {    publicstaticvoidmain(String[] args)    {          // Get a double number        doublenum1 = 62.9;          // Get the floating-point value adjacent to num        doublenextDown_Value = StrictMath.nextDown(num1);          // Print the result        System.out.println("The Next down value of "                           + num1 + " = "+ nextDown_Value);          // Get a double number        doublenum2 = 16.6226;          // Get the floating-point value adjacent to num        nextDown_Value = StrictMath.nextDown(num2);          // Print the result        System.out.println("The Next down value of "                           + num2 + " = "+ nextDown_Value);          // Get a double number        doublenum3 = 0.0;          // Get the floating-point value adjacent to num        nextDown_Value = StrictMath.nextDown(num3);          // Print the result        System.out.println("The Next down value of "                           + num3 + " = "+ nextDown_Value);    }} | 
The Next down value of 62.9 = 62.89999999999999 The Next down value of 16.6226 = 16.622599999999995 The Next down value of 0.0 = -4.9E-324
Â
nextDown(float num)
The nextDown(float num) is the inbuilt method of StrictMath class in Java which is used to get the floating point value that is adjacent to num in the direction of negative infinity. The result is NaN when argument is a NaN. It returns negative infinity when the num is negative infinity. The result is Float.MIN_VALUE when the argument is zero. The nextDown() method is equivalent to nextAfter(num, Float.NEGATIVE_INFINITY) but nextDown() runs faster than its equivalent nextAfter call.
Syntax:Â
public static float nextDown(float num)
Parameters: The method accepts one parameter num of float type which is the starting floating point value.
Return Value: The method returns the adjacent floating-point value closer to negative infinity.
Examples :Â
Input: num = 1.2f Output: 1.1999999
Below programs illustrate the Java.lang.StrictMath.nextDown() Method:
Program 1:Â
Java
| // Java program to illustrate the// Java.lang.StrictMath.nextDown() Method  importjava.lang.*;  publicclassGeeks {    publicstaticvoidmain(String[] args)    {          // Get a float number        floatnum1 = 16.622f;          // Get the floating-point value adjacent to num        floatnextDown_Value = StrictMath.nextDown(num1);          // Print the result        System.out.println("The Next down value of "                           + num1 + " = "+ nextDown_Value);          // Get a float number        floatnum2 = 91.11f;          // Get the floating-point value adjacent to num        nextDown_Value = StrictMath.nextDown(num2);          // Print the result        System.out.println("The Next down value of "                           + num2 + " = "+ nextDown_Value);          // Get a float number        floatnum3 = 0.0f;          // Get the floating-point value adjacent to num        nextDown_Value = StrictMath.nextDown(num3);          // Print the result        System.out.println("The Next down value of "                           + num3 + " = "+ nextDown_Value);    }} | 
The Next down value of 16.622 = 16.621998 The Next down value of 91.11 = 91.10999 The Next down value of 0.0 = -1.4E-45
Â


 
                                    







