420 Part II: The Java Library
Miscellaneous Math Methods
In addition to the methods just shown,Mathdefines several other methods, which are
shown here:
Method Description
static int abs(intarg) Returns the absolute value ofarg.
static long abs(longarg) Returns the absolute value ofarg.
static float abs(floatarg) Returns the absolute value ofarg.
static double abs(doublearg) Returns the absolute value ofarg.
static double ceil(doublearg) Returns the smallest whole number greater than or
equal toarg.
static double floor(doublearg) Returns the largest whole number less than or equal toarg.
static int max(intx, inty) Returns the maximum ofxandy.
static long max(longx, longy) Returns the maximum ofxandy.
static float max(floatx, floaty) Returns the maximum ofxandy.
static double max(doublex, doubley) Returns the maximum ofxandy.
static int min(intx, inty) Returns the minimum ofxandy.
static long min(longx, longy) Returns the minimum ofxandy.
static float min(floatx, floaty) Returns the minimum ofxandy.
static double min(doublex, doubley) Returns the minimum ofxandy.
static double nextAfter(doublearg,
doubletoward)
Beginning with the value ofarg,returns the next value in
the direction oftoward. Ifarg==toward,thentowardis
returned. (Added by Java SE 6.)
static float nextAfter(floatarg,
doubletoward)
Beginning with the value ofarg,returns the next value in
the direction oftoward. Ifarg==toward, thentowardis
returned. (Added by Java SE 6.)
static double nextUp(doublearg) Returns the next value in the positive direction fromarg.
(Added by Java SE 6.)
static float nextUp(floatarg) Returns the next value in the positive direction fromarg.
(Added by Java SE 6.)
static double rint(doublearg) Returns the integer nearest in value toarg.
static int round(floatarg) Returnsargrounded up to the nearestint.
static long round(doublearg) Returnsargrounded up to the nearestlong.
static float ulp(floatarg) Returns the ulp forarg.
static double ulp(doublearg) Returns the ulp forarg.
TABLE 16-16 The Rounding Methods Defined byMath