# Java Math nextDown() Method

The nextDown() method of Math class returns the floating-point number adjacent to the argument in direction of the negative infinity.

Syntax:

1. public static double nextDown (double d)
2. public static float nextDown (float f)

Parameters:

The parameters ‘d’ and ‘f’ represent the starting floating-point values.

Return Value:

The nextDown () method returns the floating-point number which is closer to negative infinity.

Special cases of the nextDown() method are as follows:

• It returns NaN, is the argument passed is NaN.
• It returns negative infinity, if the argument is negative infinity.
• It returns –Double.MIN_VALUE, is the argument is zero.

Example 1:

```public class JavaMathNextDownExample1 {
public static void main(String[] args) {
float f = 123.78f;
// returns the floating-point number which is closer to negative infinity
System.out.println("Floating-point number : "+Math.nextDown(f));
}
}```

Output:

`Floating-point number : 123.77999`

Example 2:

```public class JavaMathNextDownExample2 {
public static void main(String[] args) {
Double d = -0d;
// returns the floating-point number which is closer to negative infinity
System.out.println("Floating-point number : "+Math.nextDown(d));
}
}```

Output:

`Floating-point number : -4.9E-324`

Example 3:

```public class JavaMathNextDownExample3 {
public static void main(String[] args) {
Double d = Double.NaN;
//returns NaN, is the argument passed is NaN.
System.out.println("Floating-point number : "+Math.nextDown(d));
}
}```

Output:

`Floating-point number : NaN`

Example 4:

```public class JavaMathNextDownExample4 {
public static void main(String[] args) {
Double d = Double.NEGATIVE_INFINITY;
// returns negative infinity, if the argument is negative infinity
System.out.println("Floating-point number : "+Math.nextDown(d));
}
}```

Output:

`Floating-point number : -Infinity`

Example 5:

```public class JavaMathNextDownExample5 {
public static void main(String[] args) {
Double d = 0.0d;
//returns –Double.MIN_VALUE, is the argument is zero.
System.out.println("Floating-point number : "+Math.nextDown(d));
}
}```

Output:

`Floating-point number : -4.9E-324`