StrictMath nextUp() Method in Java Last Updated : 03 Aug, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The nextUp(double num) is an inbuilt method of StrictMath class in Java which is used to get the float value that is contiguous to num in the direction of positive infinity. The nextup() method is equivalent to nextAfter(num, Double.POSITIVE_INFINITY) but nextup() runs faster than nextAfter(). Syntax: public static double nextUp(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 positive infinity. It has three special cases: The result is NaN when argument is a NaN. It returns positive infinity when the num is positive infinity.. The result is Double.MIN_VALUE when the argument is zero. Examples: Input: num = 25.18700000 Output: 25.187000000000005 Below program illustrates the Java.lang.StrictMath.nextUp() Method: java // Java praogram to illustrate the // Java.lang.StrictMath.nextUp() Method import java.lang.*; public class Geeks { public static void main(String[] args) { double num1 = 67.1230000000; double num2 = 21.12, num3 = 0.0; // Returns floating-point value adjacent to num double nextUp_Value = StrictMath.nextUp(num1); System.out.println("The Next upper value is : " + nextUp_Value); double nextUp_Value1 = StrictMath.nextUp(num2); System.out.println("The Next upper value is : " + nextUp_Value1); double nextUp_Value2 = StrictMath.nextUp(num3); System.out.println("The Next upper value is : " + nextUp_Value2); } } Output: The Next upper value is : 67.12300000000002 The Next upper value is : 21.120000000000005 The Next upper value is : 4.9E-324 The nextUp(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 positive infinity.Float.POSITIVE_INFINITY) but nextup() runs faster than its equivalent nextAfter call. Syntax: public static float nextUp(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 positive infinity. It has three special cases: The result is NaN when argument is a NaN. It returns positive infinity when the num is positive infinity.. The result is Float.MIN_VALUE when the argument is zero. Examples : Input: num = 15.78f Output: 15.780000686645508 Below program illustrates the Java.lang.StrictMath.nextUp() Method: java // Java praogram to illustrate the // Java.lang.StrictMath.nextUp() Method import java.lang.*; public class Geeks { public static void main(String[] args) { float num1 = 73.728f; float num2 = 51.71f, num3 = 0.0f; // Returns floating-point value adjacent to num double nextUp_Value = StrictMath.nextUp(num1); System.out.println("The Next upper value is : " + nextUp_Value); double nextUp_Value1 = StrictMath.nextUp(num2); System.out.println("The Next upper value is : " + nextUp_Value1); double nextUp_Value2 = StrictMath.nextUp(num3); System.out.println("The Next upper value is : " + nextUp_Value2); } } Output: The Next upper value is : 73.7280044555664 The Next upper value is : 51.71000289916992 The Next upper value is : 1.401298464324817E-45 Comment More infoAdvertise with us Next Article Stack search() Method in Java A ankita_chowrasia Follow Improve Article Tags : Java Java-lang package Java-Functions Java-StrictMath Practice Tags : Java Similar Reads 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 StrictMath nextAfter() Method in Java The nextAfter(double start, double direction) is the inbuilt method of StrictMath class in Java which is used to get the float number, adjacent to the start in the direction of the second argument direction. This method gives rise to few conditions depending on the type and variation of parameters. 4 min read BitSet nextSetBit() method in Java BitSet is a class defined in the java.util package. It creates an array of bits represented by boolean values. Prerequisite : Java BitSet | Set 1 nextSetBit() method : This method in BitSet Class is used to return the index of the first bit that is set to true, that occurs on or after the specified 3 min read Stack peek() Method in Java The java.util.Stack.peek() method in Java is used to retrieve or fetch the first element of the Stack or the element present at the top of the Stack. The element retrieved does not get deleted or removed from the Stack. Syntax:STACK.peek()Parameters: The method does not take any parameters. Return V 2 min read Stack search() Method in Java The java.util.Stack.search(Object element) method in Java is used to search for an element in the stack and get its distance from the top. This method starts the count of the position from 1 and not from 0. The element that is on the top of the stack is considered to be at position 1. If more than o 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 Like