Determine the subsequent floating-point number that is lower than various given numbers.
System.out .println(Math.nextDown(1.0f));System. out .println(Math.nextDown(1.0));System. out .println(Math.nextDown(0.5f));System. out .println(Math.nextDown(0.5));System. out .println(Math.nextDown(Math.PI));System. out .println(Math.nextDown(3.1415927f)); |
The nextDown() method in Java retrieves the floating-point number adjacent to a given number in the negative direction, specifically the highest possible floating-point number that is less than the starting number.
For double type arguments, the returned value will be closer to the starting number than for float type arguments.
One of the following:
public static double nextDown(double start)
|
public static float nextDown(float start)
|
Parameter |
Description |
start |
Please specify the starting number. |
Returns: |
A double or float value representing the floating-point number that is adjacent to a starting number in the negative direction. |
Java Version |
1.8+ |