Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published Oct 21, 2022
Contribute to Docs

The Math.nextDown() method returns the floating-point value adjacent to the parameter provided in the direction of negative infinity.


  • The x parameter can be of type double or float.
  • The return type is of double or float.
  • Though it is the opposite of .nextAfter(), the .nextDown() method is semantically equivalent to nextAfter(d, Double.NEGATIVE_INFINITY); or nextAfter(f, Float.NEGATIVE_INFINITY);.

Note: A .nextDown() implementation may run faster than its equivalent .nextAfter() call.

Special cases include the following:

  • If x is NaN, the result is NaN.
  • If x is negative infinity, the result is negative infinity.
  • If x is zero, the result is -Double.MIN_VALUE or -Float.MIN_VALUE.


The following is an example of the .nextDown() method:

// Test.java
public class Test {
public static void main(String args[]) {
double d = 23.44;

This results in the following output:


All contributors

Looking to contribute?

Learn Java on Codecademy