Java Reference
In-Depth Information
Maximum and minimum
Two functions named max() and min() allow comparing two values to de-
termine which is the greater or the smaller. The max() method returns the
greater of two numbers,while the min() method determines the smaller.
Both methods allow operands of type int,long,float,and double.
The general form of the max() and min() functions are as follows:
public static operand max(operand a, operand b)
Operand can be of type int,long,float,or double. The max() method returns
the greater of two values.
public static operand min(operand a, operand b)
Operand can be of type int,long,float,or double. The min() method returns
the smaller of two values.
Rounding controls
Several methods in java.lang.Math and java.lang.StrictMath provide round-
ing controls over numeric operands. These methods round a floating-point
value to a whole number. The methods are as follows:
public static double ceil(double a)
Returns the smallest double value that is not less than the argument and is
equal to an integer. The following are special cases:
1. If the argument value is already equal to an integer,then the result is the
same as the argument.
2. If the argument is NaN or an infinity or positive zero or negative zero,then
the result is the same as the argument.
3. If the argument value is less than zero but greater than -1.0,then the result is
negative zero.
public static double floor(double a)
Returns the largest double value that is not greater than the argument and is
equal to an integer. The following are special cases:
1. If the argument is already equal to an integer,then the result is the same as
the argument.
2. If the argument is NaN or an infinity or positive zero or negative zero,then
the result is the same as the argument.
Search WWH ::




Custom Search