StrictMath min() Method in Java with Examples Last Updated : 25 Jul, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The java.lang.StrictMath.min() method returns the smaller of two values. There are four variations of this method with different types of parameters passed. All of them are discussed below : min(double num1, double num2) is the inbuilt method of StrictMath class which is used to get the least of given two double values arguments. It returns NaN when any of the arguments is NaN. It returns the same value when num1 and num2 have the same value. min() method assumes negative zero to be strictly smaller than positive zero.It returns negative zero when one argument is positive zero and the other is negative zero. Syntax : public static double min(double num1, double num2) Parameters : The method accepts a two parameter : num1 of double type representing one parameter num2 of double type representing another parameter Return Value : The method returns the least of num1 and num2. Examples : Input: num1 = 9 nm2 = 99 Output: 9.0 Below programs illustrate the Java.lang.StrictMath.min() Method. Program 1: java // Java praogram to illustrate the // Java.lang.StrictMath.min() Method // with double values passed // as parameters import java.lang.*; public class Geeks { public static void main(String[] args) { double num1 = 10, num2 = 40, num3 = -25, num4 = -25, num5 = -17; double min_Value = StrictMath.min(num1, num2); System.out.println("min of the two num is " + min_Value); min_Value = StrictMath.min(num3, num4); System.out.println("min of the two num is " + min_Value); min_Value = StrictMath.min(num4, num5); System.out.println("min of the two num is " + min_Value); } } Output: min of the two num is 10.0 min of the two num is -25.0 min of the two num is -25.0 Example of Error Condition : Java // Java praogram to illustrate the // error condition in // Java.lang.StrictMath.min() Method import java.lang.*; public class Geeks { public static void main(String[] args) { double num1 = 51, num2 = 71, num3 = 3, num4 = -93, num5 = -93; double a = 0.0; num1 = a / 0.0; double min_Value = StrictMath.min(num1, a); System.out.println("min of the two num is " + min_Value); } } Output: min of the two num is NaN The min(float num1, float num2) is the inbuilt method of StrictMath class which is used to get the least of given two float values arguments.It returns NaN when any of the arguments is NaN.It returns the same value when num1 and num2 have the same value. min() method assumes negative zero to be strictly smaller than positive zero.It returns negative zero when one argument is positive zero and the other is negative zero. Syntax : public static float min(float num1, float num2) Parameters : The method accepts a two parameter : num1 of float type representing one parameter num2 of float type representing another parameter Return Value : The method returns the least of num1 and num2. Examples : Input: num1 = 9 nm2 = 5 Output: 5.0 Below programs illustrate the Java.lang.StrictMath.min() Method. Program 1: java // Java praogram to illustrate the // Java.lang.StrictMath.min() Method // with float values passed // as parameters import java.lang.*; public class Geeks { public static void main(String[] args) { float num1 = 28, num2 = 82, num3 = -23, num4 = -23, num5 = -11; float min_Value = StrictMath.min(num1, num2); System.out.println("min of the two num is " + min_Value); min_Value = StrictMath.min(num3, num4); System.out.println("min of the two num is " + min_Value); min_Value = StrictMath.min(num4, num5); System.out.println("min of the two num is " + min_Value); } } Output: min of the two num is 28.0 min of the two num is -23.0 min of the two num is -23.0 The min(int num1, int num2) is the inbuilt method of StrictMath class which is used to get the least of given two int values arguments.It returns NaN when any of the arguments is NaN.It returns the same value when num1 and num2 have the same value. min() method assumes negative zero to be strictly smaller than positive zero.Simply the argument closer to the value of Integer.MIN_VALUE is the result. Syntax : public static int min(int num1, int num2) Parameters : The method accepts a two parameter : num1 of int type representing one parameter num2 of int type representing another parameter Return Value : The method returns the least of num1 and num2. Examples : Input: num1 = 61 nm2 = 18 Output: 5.0 Below programs illustrate the Java.lang.StrictMath.min() Method. Program 1: java // Java praogram to illustrate the // Java.lang.StrictMath.min() Method // with int values passed // as parameters import java.lang.*; public class Geeks { public static void main(String[] args) { int num1 = 51, num2 = 71, num3 = -74, num4 = -93, num5 = -93; double min_Value = StrictMath.min(num1, num2); System.out.println("min of the two num is " + min_Value); min_Value = StrictMath.min(num3, num4); System.out.println("min of the two num is " + min_Value); min_Value = StrictMath.min(num4, num5); System.out.println("min of the two num is " + min_Value); } } Output: min of the two num is 51.0 min of the two num is -93.0 min of the two num is -93.0 The min(long num1, long num2) is the inbuilt method of StrictMath class which is used to get the least of given two long values arguments.It returns NaN when any of the arguments is NaN.It returns the same value when num1 and num2 have the same value. min() method assumes negative zero to be strictly smaller than positive zero.Simply the argument closer to the value of Long.MIN_VALUE is the result. Syntax : public static long min(long num1, long num2) Parameters : The method accepts a two parameter : num1 of long type representing one parameter num2 of long type representing another parameter Return Value : The method returns the least of num1 and num2. Examples : Input: num1 = 51617 nm2 = 1345 Output: 1345.0 Below programs illustrate the Java.lang.StrictMath.min() Method. Program 1: java // Java praogram to illustrate the // Java.lang.StrictMath.min() Method // with long values passed // as parameters import java.lang.*; public class Geeks { public static void main(String[] args) { long num1 = 265626, num2 = 66671, num3 = -776264, num4 = -9263, num5 = -97623; double min_Value = StrictMath.min(num1, num2); System.out.println("min of the two num is " + min_Value); min_Value = StrictMath.min(num3, num4); System.out.println("min of the two num is " + min_Value); min_Value = StrictMath.min(num4, num5); System.out.println("min of the two num is " + min_Value); } } Output: min of the two num is 66671.0 min of the two num is -776264.0 min of the two num is -97623.0 Comment More infoAdvertise with us Next Article StrictMath min() Method in Java with Examples A ankita_chowrasia Follow Improve Article Tags : Java Java-lang package java-math Practice Tags : Java Similar Reads StrictMath max() Method in Java With Examples The java.lang.StrictMath.max() method returns the larger of two values. There are four variations of this method with different types of parameters passed. All of them are discussed below : The max(double num1, double num2)is the inbuilt method which is used to get the maximum of two given double va 6 min read Stream min() method in Java with Examples Stream.min() returns the minimum element of the stream based on the provided Comparator. A Comparator is a comparison function, which imposes a total ordering on some collection of objects. min() is a terminal operation which combines stream elements and returns a summary result. So, min() is a spec 3 min read StrictMath ceil() Method in Java with Examples All methods of java.lang.StrictMath class : Set 1, Set 2The java.lang.StrictMath.ceil() is an inbuilt method in Java is used to return the smallest double value, greater than or equal to the given double argument and equal to an integer. It gives rise to three special results: The result is the same 2 min read Java Guava | Shorts.min() method with Examples Shorts.min() method of Guava's Shorts Class is used to find the least value present in an array. The value returned by this method is the smallest short value in the specified array. Syntax: public static short min(short... array) Parameters: This method takes a mandatory parameter array which is a 2 min read ValueRange of() method in Java with Examples The of() method of ValueRange class helps us to Obtains value range based on parameters passed to it. There are three types of of() methods based on parameters passed to it. of(long min, long max): This method help us to get a fixed value range where the minimum and maximum values are fixed. Syntax: 3 min read Like