Max, min value
static double max(double a, double b)
- Returns the greater of two double values.
static float max(float a, float b)
- Returns the greater of two float values.
static int max(int a, int b)
- Returns the greater of two int values.
static long max(long a, long b)
- Returns the greater of two long values.
static double min(double a, double b)
- Returns the smaller of two double values.
static float min(float a, float b)
- Returns the smaller of two float values.
static int min(int a, int b)
- Returns the smaller of two int values.
static long min(long a, long b)
- Returns the smaller of two long values.
public class Main {
public static void main(String[] args) {
System.out.println(Math.max(2,1.2));
System.out.println(Math.min(2,1.2));
}
}
The output:
2.0
1.2
Home
Java Book
Essential Classes
Java Book
Essential Classes
Math:
- Math class
- Constant E and PI
- Get the absolute value
- sin, cos, tan: Trigonometric functions
- Cube root and square root
- Ceilling and flooring value
- Copy sign
- Raise the power
- Get exponent
- sqrt(x2 +y2)
- IEEE remainder
- logarithm
- Max, min value
- Next value
- Math Random
- Round to int to double
- Round a value to integer
- value * 2^ scaleFactor
- Get the sign
- Degree to Radian, and Radian to Degree
- Returns the size of an ulp of the argument