Java Math nextDown() Method Last Updated : 12 May, 2025 Comments Improve Suggest changes Like Article Like Report The nextDown() is a built-in Math function in Java that returns the next smaller floating-point number adjacent to the parameter provided in the direction of negative infinity. The nextDown() implementation may run faster than its equivalent nextAfter() call. The nextDown() method is overloaded which means that we have more than one method with the same name under the Math class. Two overloaded methods of the nextDown():double type: nextDown(double d)float type: nextDown(float f)Syntax of nextDown() Methodpublic static double Math.nextDown(double d)public static float Math.nextDown(float f)Parameters: d or f: The floating-point number that is double or float, for which we want to find the next lower representable value.Returns: It returns the adjacent floating-point value closer to negative infinity.Special Values:If the input is NaN, we will get result NaN.If the input is 0.0, we will get the result as the smallest negative value representable, for example, -Double.MIN_VALUE or -Float.MIN_VALUE.If the input is negative infinity, the result is also negative infinity.Examples of Java Math nextDown() MethodExample 1: In this example, we will see how nextDown() method works in Java. Java // Java program to demonstrate Math.nextDown() method import java.lang.Math; public class Geeks { public static void main(String[] args) { double x = 50.5; float y = 19.2f; System.out.println("Next down of 50.5 (double): " + Math.nextDown(x)); System.out.println("Next down of 19.2f (float): " + Math.nextDown(y)); } } OutputNext down of 50.5 (double): 50.49999999999999 Next down of 19.2f (float): 19.199999 Example 2: In this example, we are going to try with special values like NaN, 0.0, and negative infinity. Java // Java program to demonstrate nextDown() // with special floating-point values import java.lang.Math; public class Geeks { public static void main(String[] args) { System.out.println("Next down of NaN: " + Math.nextDown(Double.NaN)); System.out.println("Next down of 0.0f: " + Math.nextDown(0.0f)); System.out.println("Next down of -Infinity: " + Math.nextDown(Double.NEGATIVE_INFINITY)); } } OutputNext down of NaN: NaN Next down of 0.0f: -1.4E-45 Next down of -Infinity: -Infinity Important Points:This method works with both float and double.It returns the closest representable value which is smaller than the input.This method id useful for numeriacal methods or any kind of comparison operations. Comment More infoAdvertise with us Next Article Java Math nextUp() method with Examples N Niraj_Pandey Follow Improve Article Tags : Java DSA Java-lang package java-math Practice Tags : Java Similar Reads Java Math nextDown() method with Examples The nextDown() is a built-in Math function in Java that returns the next smaller floating-point number adjacent to the parameter provided in the direction of negative infinity. The nextDown() implementation may run faster than its equivalent nextAfter() call. The nextDown() method is overloaded whic 2 min read Java Math nextUp() method with Examples The Math.nextUp() method in Java comes under java.lang.Math package. This method returns the floating-point value that is next greater than the given input and moving in the direction of positive infinity. This method is very useful when we need to find the smallest representable number that is grea 3 min read Java Math nextAfter() method with Example The java.lang.Math.nextAfter() returns the floating-point number adjacent to the first argument in the direction of the second argument. If both arguments are equal then the second argument is returned. Syntax of nextAfter() method// datatype can be float or double. public static dataType nextAfter( 2 min read StrictMath nextDown() Method in Java 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 3 min read SortedSet last() method in Java The last() method of SortedSet interface in Java is used to return the last i.e., the highest element currently in this set.Syntax: E last() Where, E is the type of element maintained by this Set.Parameters: This function does not accepts any parameter.Return Value: It returns the last or the highes 2 min read Vector lastElement() Method in Java The java.util.vector.lastElement() method in Java is used to retrieve or fetch the last element of the Vector. It returns the element present at the last index of the vector. Syntax: Vector.lastElement() Parameters: The method does not take any parameter. Return Value: The method returns the last el 2 min read stream.limit() method in Java Prerequisite : Streams in Java8 The limit(long N) is a method of java.util.stream.Stream object. This method takes one (long N) as an argument and returns a stream of size no more than N. limit() can be quite expensive on ordered parallel pipelines, if the value of N is large, because limit(N) is co 2 min read Random next() method in Java with Examples The next() method of Random class returns the next pseudorandom value from the random number generator's sequence. Syntax: protected int next(int bits) Parameters: The function accepts a single parameter bits which are the random bits. Return Value: This method returns the next pseudorandom number. 1 min read Java Vector elements() Method In Java, the elements() method is used to return an enumeration of the elements in the Vector. This method allows you to iterate over the elements of a Vector using an Enumeration, which provides methods for checking if there are more elements and retrieving the next element.Example 1: Below is the 2 min read Java Math incrementExact(int x) method The java.lang.Math.incrementExact() is a built-in math function in java which returns the argument incremented by one.It throws an exception if the result overflows an int.As incrementExact(int x) is static, so object creation is not required. Syntax : public static int incrementExact(int x) Paramet 1 min read Like