28
 OVERV IEW PACKAG E CLASS USE TREE DEPRECATED INDEX HELP  Java™ Platform Standard Ed. 8 PREV CLASS NEX T CLASS FRAMES NO FRAMES ALL C LASSES SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD compact1, compact2, compact3  java.lang Class Math  java.lang. Object  java.lang. Math pu b l i c fi nal cl a ss M at h exten ds O bj ect The class M at h contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions. Unlike some of the numeric methods of class St r i ctMat h, all implementations of t he equivalent functions of class M at h are not defined to return the bit-for-bit same results. This relaxation permits better-performing implementations where strict reproducibility is not required. By default many of the M at h methods simply call the equivalent method in S t ri ctM at h for their implementation. Code generators are encouraged to use platform-specific native libraries or microprocessor instru ctions, whe re available , to provide higher-perform ance implementations of M at h methods. Such higher-performance implementations still must conform to the specification for M at h. The quality of implementation specifications concern two properties, accuracy of the returned result and monotonicity of the method. Accuracy of the floating-point M at h methods is measured in terms of ulps, units in the last place. For a given floating-point format, an ulp of a specific real number value is the distance between the two flo ating-point values bracketing that nu merical value. When discussing the accur acy of a meth od as a whole rather than at a specific argum ent, the number of ulps cited is for the worst- case error at any arg ument. If a method alwa ys has an error less than 0.5 ulps, the m ethod alwa ys return s the floating-point number nearest the exact result; such a method is correctly rounded. A correct ly rounded met hod is generally the best a floating-point approximation can be; however, it is impractical for many floating-point methods to be correctly rounded. Instead, for the M at h class, a larger error bound of 1 or 2 ulps is allo wed for certain methods. Informally, with a 1 ulp error bound, when the exact result is a representable number , the exact result should be ret urned as the computed result; otherwise, either of the two floating-point values which bracket the exact result may be returned. For exact results large in magnitude, one of the endpoints of the bracket may be infinite. Besi des accuracy at individual arguments, maintaining proper relations between the meth od at different arguments is also important. Therefore, most methods with more than 0.5 ulp errors are required to be semi-monotonic: whenever the mathematical function is non-decr easing, so is the floating-point approximation, likew ise, w henever the m athemat ical function is non-increasing, so is the floating-point approximation. Not all approximations that have 1 ulp accuracy will automatically meet the monotonicity requirements. The platform uses signed two's complement integer arithmetic with int and long primitive t ypes. The develo per should choose the primitive type to ensure that arithmetic operations consistently produce correct results, which in some cases means the operations will not overflow the range of values o f the computation. The best pract ice is to choose the primitive ty pe and algorithm t o avoid overflow. In cases where the size is i nt  or l ong and overflow e rrors need to be det ected, the methods addExact , sub t r act Ex act , mu l t i p l yE xa ct , and t oI n t E xa ct  throw an A r i t h met i cE xcept i on when the results overflow. For other arith metic operat ions such as divide, absol ute value, increment, decrem ent, and negation overflow occurs only with a specific minimum or maxim um v alue and should be checked against the minimum or maximum as appropriate. Since:  J D K 1. 0 Field Summary Modi fi er an d Type Fi el d and D es cription stati c d oubl e E The do ub l e value that is closer than any other to e, the base of the natural logarithms. stati c d oubl e PI The do ub l e value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter. Method Summary Fields converted by Web2PDFConvert.com

Math Class

Embed Size (px)

DESCRIPTION

wewes

Citation preview

  • OVERVIEW PACKAGE CLASS USE TREE DEPRECATED INDEX HELPJava PlatformStandard Ed. 8

    PREV CLASS NEXT CLASS FRAMES NO FRAMES ALL CLASSES

    SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

    compact1, compact2, compact3java.lang

    Class Math

    java.lang.Objectjava.lang.Math

    publ i c f i nal cl ass Mat hext ends Obj ect

    The class Mat h contains methods for performing basic numeric operations such as the elementary exponential, logarithm, squareroot, and trigonometric functions.

    Unlike some of the numeric methods of class St r i ct Mat h, all implementations of the equivalent functions of class Mat h are notdefined to return the bit-for-bit same results. This relaxation permits better-performing implementations where strictreproducibility is not required.

    By default many of the Mat h methods simply call the equivalent method in St r i ct Mat h for their implementation. Code generators areencouraged to use platform-specific native libraries or microprocessor instructions, where available, to provide higher-performanceimplementations of Mat h methods. Such higher-performance implementations still must conform to the specification for Mat h.

    The quality of implementation specifications concern two properties, accuracy of the returned result and monotonicity of themethod. Accuracy of the floating-point Mat h methods is measured in terms of ulps, units in the last place. For a given floating-pointformat, an ulp of a specific real number value is the distance between the two floating-point values bracketing that numerical value.When discussing the accuracy of a method as a whole rather than at a specific argument, the number of ulps cited is for the worst-case error at any argument. If a method always has an error less than 0.5 ulps, the method always returns the floating-point numbernearest the exact result; such a method is correctly rounded. A correctly rounded method is generally the best a floating-pointapproximation can be; however, it is impractical for many floating-point methods to be correctly rounded. Instead, for the Mat h class,a larger error bound of 1 or 2 ulps is allowed for certain methods. Informally, with a 1 ulp error bound, when the exact result is arepresentable number, the exact result should be returned as the computed result; otherwise, either of the two floating-point valueswhich bracket the exact result may be returned. For exact results large in magnitude, one of the endpoints of the bracket may beinfinite. Besides accuracy at individual arguments, maintaining proper relations between the method at different arguments is alsoimportant. Therefore, most methods with more than 0.5 ulp errors are required to be semi-monotonic: whenever the mathematicalfunction is non-decreasing, so is the floating-point approximation, likewise, whenever the mathematical function is non-increasing, sois the floating-point approximation. Not all approximations that have 1 ulp accuracy will automatically meet the monotonicityrequirements.

    The platform uses signed two's complement integer arithmetic with int and long primitive types. The developer should choose theprimitive type to ensure that arithmetic operations consistently produce correct results, which in some cases means the operationswill not overflow the range of values of the computation. The best practice is to choose the primitive type and algorithm to avoidoverflow. In cases where the size is i nt or l ong and overflow errors need to be detected, the methods addExact , subt ract Exact ,mul t i pl yExact , and t oI nt Exact throw an Ar i t hmet i cExcept i on when the results overflow. For other arithmetic operations such asdivide, absolute value, increment, decrement, and negation overflow occurs only with a specific minimum or maximum value andshould be checked against the minimum or maximum as appropriate.

    Since:

    J DK1. 0

    Field Summary

    Modifier and Type Field and Description

    st at i c doubl e EThe doubl e value that is closer than any other to e, the base of the natural logarithms.

    st at i c doubl e PIThe doubl e value that is closer than any other to pi, the ratio of the circumference of a circleto its diameter.

    Method Summary

    Fields

    converted by Web2PDFConvert.com

  • Modifier and Type Method and Description

    st at i c doubl e abs( doubl e a)Returns the absolute value of a doubl e value.

    st at i c f l oat abs( f l oat a)Returns the absolute value of a f l oat value.

    st at i c i nt abs( i nt a)Returns the absolute value of an i nt value.

    st at i c l ong abs( l ong a)Returns the absolute value of a l ong value.

    st at i c doubl e acos( doubl e a)Returns the arc cosine of a value; the returned angle is in the range 0.0 through pi.

    st at i c i nt addExact ( i nt x, i nt y)Returns the sum of its arguments, throwing an exception if the result overflows an i nt .

    st at i c l ong addExact ( l ong x, l ong y)Returns the sum of its arguments, throwing an exception if the result overflows a l ong.

    st at i c doubl e asi n( doubl e a)Returns the arc sine of a value; the returned angle is in the range -pi/2 through pi/2.

    st at i c doubl e at an( doubl e a)Returns the arc tangent of a value; the returned angle is in the range -pi/2 through pi/2.

    st at i c doubl e at an2( doubl e y, doubl e x)Returns the angle theta from the conversion of rectangular coordinates (x, y) to polarcoordinates (r, theta).

    st at i c doubl e cbr t ( doubl e a)Returns the cube root of a doubl e value.

    st at i c doubl e cei l ( doubl e a)Returns the smallest (closest to negative infinity) doubl e value that is greater than or equal tothe argument and is equal to a mathematical integer.

    st at i c doubl e copySi gn( doubl e magni t ude, doubl e si gn)Returns the first floating-point argument with the sign of the second floating-point argument.

    st at i c f l oat copySi gn( f l oat magni t ude, f l oat si gn)Returns the first floating-point argument with the sign of the second floating-point argument.

    st at i c doubl e cos( doubl e a)Returns the trigonometric cosine of an angle.

    st at i c doubl e cosh( doubl e x)Returns the hyperbolic cosine of a doubl e value.

    st at i c i nt decrement Exact ( i nt a)Returns the argument decremented by one, throwing an exception if the result overflows ani nt .

    st at i c l ong decrement Exact ( l ong a)Returns the argument decremented by one, throwing an exception if the result overflows al ong.

    st at i c doubl e exp( doubl e a)Returns Euler's number e raised to the power of a doubl e value.

    st at i c doubl e expm1( doubl e x)Returns ex -1.

    st at i c doubl e f l oor ( doubl e a)Returns the largest (closest to positive infinity) doubl e value that is less than or equal to theargument and is equal to a mathematical integer.

    All Methods Static Methods Concrete Methods

    converted by Web2PDFConvert.com

  • st at i c i nt f l oorDi v( i nt x, i nt y)Returns the largest (closest to positive infinity) i nt value that is less than or equal to thealgebraic quotient.

    st at i c l ong f l oorDi v( l ong x, l ong y)Returns the largest (closest to positive infinity) l ong value that is less than or equal to thealgebraic quotient.

    st at i c i nt f l oorMod( i nt x, i nt y)Returns the floor modulus of the i nt arguments.

    st at i c l ong f l oorMod( l ong x, l ong y)Returns the floor modulus of the l ong arguments.

    st at i c i nt get Exponent ( doubl e d)Returns the unbiased exponent used in the representation of a doubl e.

    st at i c i nt get Exponent ( f l oat f )Returns the unbiased exponent used in the representation of a f l oat .

    st at i c doubl e hypot ( doubl e x, doubl e y)Returns sqrt(x2 +y2) without intermediate overflow or underflow.

    st at i c doubl e I EEEremai nder ( doubl e f 1, doubl e f 2)Computes the remainder operation on two arguments as prescribed by the IEEE 754standard.

    st at i c i nt i ncrement Exact ( i nt a)Returns the argument incremented by one, throwing an exception if the result overflows ani nt .

    st at i c l ong i ncrement Exact ( l ong a)Returns the argument incremented by one, throwing an exception if the result overflows al ong.

    st at i c doubl e l og( doubl e a)Returns the natural logarithm (base e) of a doubl e value.

    st at i c doubl e l og10( doubl e a)Returns the base 10 logarithm of a doubl e value.

    st at i c doubl e l og1p( doubl e x)Returns the natural logarithm of the sum of the argument and 1.

    st at i c doubl e max( doubl e a, doubl e b)Returns the greater of two doubl e values.

    st at i c f l oat max( f l oat a, f l oat b)Returns the greater of two f l oat values.

    st at i c i nt max( i nt a, i nt b)Returns the greater of two i nt values.

    st at i c l ong max( l ong a, l ong b)Returns the greater of two l ong values.

    st at i c doubl e mi n( doubl e a, doubl e b)Returns the smaller of two doubl e values.

    st at i c f l oat mi n( f l oat a, f l oat b)Returns the smaller of two f l oat values.

    st at i c i nt mi n( i nt a, i nt b)Returns the smaller of two i nt values.

    st at i c l ong mi n( l ong a, l ong b)Returns the smaller of two l ong values.

    st at i c i nt mul t i pl yExact ( i nt x, i nt y)Returns the product of the arguments, throwing an exception if the result overflows an i nt .

    st at i c l ong mul t i pl yExact ( l ong x, l ong y)Returns the product of the arguments, throwing an exception if the result overflows a l ong.

    converted by Web2PDFConvert.com

  • st at i c i nt negat eExact ( i nt a)Returns the negation of the argument, throwing an exception if the result overflows an i nt .

    st at i c l ong negat eExact ( l ong a)Returns the negation of the argument, throwing an exception if the result overflows a l ong.

    st at i c doubl e next Af t er ( doubl e st ar t , doubl e di rect i on)Returns the floating-point number adjacent to the first argument in the direction of thesecond argument.

    st at i c f l oat next Af t er ( f l oat st ar t , doubl e di rect i on)Returns the floating-point number adjacent to the first argument in the direction of thesecond argument.

    st at i c doubl e next Down( doubl e d)Returns the floating-point value adjacent to d in the direction of negative infinity.

    st at i c f l oat next Down( f l oat f )Returns the floating-point value adjacent to f in the direction of negative infinity.

    st at i c doubl e next Up( doubl e d)Returns the floating-point value adjacent to d in the direction of positive infinity.

    st at i c f l oat next Up( f l oat f )Returns the floating-point value adjacent to f in the direction of positive infinity.

    st at i c doubl e pow( doubl e a, doubl e b)Returns the value of the first argument raised to the power of the second argument.

    st at i c doubl e random( )Returns a doubl e value with a positive sign, greater than or equal to 0. 0 and less than 1. 0.

    st at i c doubl e r i nt ( doubl e a)Returns the doubl e value that is closest in value to the argument and is equal to amathematical integer.

    st at i c l ong round( doubl e a)Returns the closest l ong to the argument, with ties rounding to positive infinity.

    st at i c i nt round( f l oat a)Returns the closest i nt to the argument, with ties rounding to positive infinity.

    st at i c doubl e scal b( doubl e d, i nt scal eFact or )Returns d 2scal eFact or rounded as if performed by a single correctly rounded floating-point multiply to a member of the double value set.

    st at i c f l oat scal b( f l oat f , i nt scal eFact or )Returns f 2scal eFact or rounded as if performed by a single correctly rounded floating-point multiply to a member of the float value set.

    st at i c doubl e si gnum( doubl e d)Returns the signum function of the argument; zero if the argument is zero, 1.0 if theargument is greater than zero, -1.0 if the argument is less than zero.

    st at i c f l oat si gnum( f l oat f )Returns the signum function of the argument; zero if the argument is zero, 1.0f if theargument is greater than zero, -1.0f if the argument is less than zero.

    st at i c doubl e si n( doubl e a)Returns the trigonometric sine of an angle.

    st at i c doubl e si nh( doubl e x)Returns the hyperbolic sine of a doubl e value.

    st at i c doubl e sqr t ( doubl e a)Returns the correctly rounded positive square root of a doubl e value.

    st at i c i nt subt ract Exact ( i nt x, i nt y)Returns the difference of the arguments, throwing an exception if the result overflows an i nt .

    st at i c l ong subt ract Exact ( l ong x, l ong y)Returns the difference of the arguments, throwing an exception if the result overflows a l ong.

    converted by Web2PDFConvert.com

  • st at i c doubl e t an( doubl e a)Returns the trigonometric tangent of an angle.

    st at i c doubl e t anh( doubl e x)Returns the hyperbolic tangent of a doubl e value.

    st at i c doubl e t oDegrees( doubl e angrad)Converts an angle measured in radians to an approximately equivalent angle measured indegrees.

    st at i c i nt t oI nt Exact ( l ong val ue)Returns the value of the l ong argument; throwing an exception if the value overflows an i nt .

    st at i c doubl e t oRadi ans( doubl e angdeg)Converts an angle measured in degrees to an approximately equivalent angle measured inradians.

    st at i c doubl e ul p( doubl e d)Returns the size of an ulp of the argument.

    st at i c f l oat ul p( f l oat f )Returns the size of an ulp of the argument.

    Methods inherited from class java.lang.Object

    cl one, equal s, f i nal i ze, get Cl ass, hashCode, not i f y, not i f yAl l , t oSt r i ng, wai t , wai t , wai t

    Field Detail

    E

    publ i c st at i c f i nal doubl e E

    The doubl e value that is closer than any other to e, the base of the natural logarithms.

    See Also:

    Const ant Fi el d Val ues

    PI

    publ i c st at i c f i nal doubl e PI

    The doubl e value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.

    See Also:

    Const ant Fi el d Val ues

    Method Detail

    sin

    publ i c st at i c doubl e si n( doubl e a)

    Returns the trigonometric sine of an angle. Special cases:If the argument is NaN or an infinity, then the result is NaN.If the argument is zero, then the result is a zero with the same sign as the argument.

    The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.

    Parameters:

    a - an angl e, i n radi ans.Returns:

    t he si ne of t he argument .

    converted by Web2PDFConvert.com

  • cos

    publ i c st at i c doubl e cos( doubl e a)

    Returns the trigonometric cosine of an angle. Special cases:If the argument is NaN or an infinity, then the result is NaN.

    The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.

    Parameters:

    a - an angl e, i n radi ans.Returns:

    t he cosi ne of t he argument .

    tan

    publ i c st at i c doubl e t an( doubl e a)

    Returns the trigonometric tangent of an angle. Special cases:If the argument is NaN or an infinity, then the result is NaN.If the argument is zero, then the result is a zero with the same sign as the argument.

    The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.

    Parameters:

    a - an angl e, i n radi ans.Returns:

    t he t angent of t he argument .

    asin

    publ i c st at i c doubl e asi n( doubl e a)

    Returns the arc sine of a value; the returned angle is in the range -pi/2 through pi/2. Special cases:If the argument is NaN or its absolute value is greater than 1, then the result is NaN.If the argument is zero, then the result is a zero with the same sign as the argument.

    The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.

    Parameters:

    a - t he val ue whose arc si ne i s t o be ret urned.Returns:

    t he arc si ne of t he argument .

    acos

    publ i c st at i c doubl e acos( doubl e a)

    Returns the arc cosine of a value; the returned angle is in the range 0.0 through pi. Special case:If the argument is NaN or its absolute value is greater than 1, then the result is NaN.

    The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.

    Parameters:

    a - t he val ue whose arc cosi ne i s t o be ret urned.Returns:

    t he arc cosi ne of t he argument .

    atan

    publ i c st at i c doubl e at an( doubl e a)

    Returns the arc tangent of a value; the returned angle is in the range -pi/2 through pi/2. Special cases:If the argument is NaN, then the result is NaN.If the argument is zero, then the result is a zero with the same sign as the argument.

    The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.

    converted by Web2PDFConvert.com

  • Parameters:

    a - t he val ue whose arc t angent i s t o be ret urned.Returns:

    t he arc t angent of t he argument .

    toRadians

    publ i c st at i c doubl e t oRadi ans( doubl e angdeg)

    Converts an angle measured in degrees to an approximately equivalent angle measured in radians. The conversion fromdegrees to radians is generally inexact.

    Parameters:

    angdeg - an angl e, i n degreesReturns:

    t he measurement of t he angl e angdeg i n radi ans.Since:

    1. 2

    toDegrees

    publ i c st at i c doubl e t oDegrees( doubl e angrad)

    Converts an angle measured in radians to an approximately equivalent angle measured in degrees. The conversion fromradians to degrees is generally inexact; users should not expect cos( t oRadi ans( 90. 0) ) to exactly equal 0. 0.

    Parameters:

    angrad - an angl e, i n radi ansReturns:

    t he measurement of t he angl e angrad i n degrees.Since:

    1. 2

    exp

    publ i c st at i c doubl e exp( doubl e a)

    Returns Euler's number e raised to the power of a doubl e value. Special cases:If the argument is NaN, the result is NaN.If the argument is positive infinity, then the result is positive infinity.If the argument is negative infinity, then the result is positive zero.

    The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.

    Parameters:

    a - t he exponent t o rai se e t o.Returns:

    t he val ue ea, where e i s t he base of t he nat ural l ogar i t hms.

    log

    publ i c st at i c doubl e l og( doubl e a)

    Returns the natural logarithm (base e) of a doubl e value. Special cases:If the argument is NaN or less than zero, then the result is NaN.If the argument is positive infinity, then the result is positive infinity.If the argument is positive zero or negative zero, then the result is negative infinity.

    The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.

    Parameters:

    a - a val ueReturns:

    converted by Web2PDFConvert.com

  • t he val ue l n a, t he nat ural l ogar i t hm of a.

    log10

    publ i c st at i c doubl e l og10( doubl e a)

    Returns the base 10 logarithm of a doubl e value. Special cases:If the argument is NaN or less than zero, then the result is NaN.If the argument is positive infinity, then the result is positive infinity.If the argument is positive zero or negative zero, then the result is negative infinity.If the argument is equal to 10n for integer n, then the result is n.

    The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.

    Parameters:

    a - a val ueReturns:

    t he base 10 l ogar i t hm of a.Since:

    1. 5

    sqrt

    publ i c st at i c doubl e sqr t ( doubl e a)

    Returns the correctly rounded positive square root of a doubl e value. Special cases:If the argument is NaN or less than zero, then the result is NaN.If the argument is positive infinity, then the result is positive infinity.If the argument is positive zero or negative zero, then the result is the same as the argument.

    Otherwise, the result is the doubl e value closest to the true mathematical square root of the argument value.

    Parameters:

    a - a val ue.Returns:

    t he posi t i ve square root of a. I f t he argument i s NaN or l ess t han zero, t he resul t i s NaN.

    cbrt

    publ i c st at i c doubl e cbr t ( doubl e a)

    Returns the cube root of a doubl e value. For positive finite x, cbr t ( - x) == - cbr t ( x) ; that is, the cube root of a negative value isthe negative of the cube root of that value's magnitude. Special cases:

    If the argument is NaN, then the result is NaN.If the argument is infinite, then the result is an infinity with the same sign as the argument.If the argument is zero, then the result is a zero with the same sign as the argument.

    The computed result must be within 1 ulp of the exact result.

    Parameters:

    a - a val ue.Returns:

    t he cube root of a.Since:

    1. 5

    IEEEremainder

    publ i c st at i c doubl e I EEEremai nder ( doubl e f 1, doubl e f 2)

    Computes the remainder operation on two arguments as prescribed by the IEEE 754 standard. The remainder value ismathematically equal to f 1 - f 2 n, where n is the mathematical integer closest to the exact mathematical value of thequotient f 1/ f 2, and if two mathematical integers are equally close to f 1/ f 2, then n is the integer that is even. If the remainderis zero, its sign is the same as the sign of the first argument. Special cases:

    If either argument is NaN, or the first argument is infinite, or the second argument is positive zero or negative zero, then

    converted by Web2PDFConvert.com

  • the result is NaN.If the first argument is finite and the second argument is infinite, then the result is the same as the first argument.

    Parameters:

    f 1 - t he di vi dend.

    f 2 - t he di vi sor .Returns:

    t he remai nder when f 1 i s di vi ded by f 2.

    ceil

    publ i c st at i c doubl e cei l ( doubl e a)

    Returns the smallest (closest to negative infinity) doubl e value that is greater than or equal to the argument and is equal to amathematical integer. Special cases:

    If the argument value is already equal to a mathematical integer, then the result is the same as the argument.If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.If the argument value is less than zero but greater than -1.0, then the result is negative zero.

    Note that the value of Mat h. cei l ( x) is exactly the value of - Mat h. f l oor ( - x) .

    Parameters:

    a - a val ue.Returns:

    t he smal l est ( cl osest t o negat i ve i nf i ni t y) f l oat i ng- poi nt val ue t hat i s great er t han or equal t o t he argumentand i s equal t o a mat hemat i cal i nt eger .

    floor

    publ i c st at i c doubl e f l oor ( doubl e a)

    Returns the largest (closest to positive infinity) doubl e value that is less than or equal to the argument and is equal to amathematical integer. Special cases:

    If the argument value is already equal to a mathematical integer, then the result is the same as the argument.If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.

    Parameters:

    a - a val ue.Returns:

    t he l argest ( cl osest t o posi t i ve i nf i ni t y) f l oat i ng- poi nt val ue t hat l ess t han or equal t o t he argument and i sequal t o a mat hemat i cal i nt eger .

    rint

    publ i c st at i c doubl e r i nt ( doubl e a)

    Returns the doubl e value that is closest in value to the argument and is equal to a mathematical integer. If two doubl e valuesthat are mathematical integers are equally close, the result is the integer value that is even. Special cases:

    If the argument value is already equal to a mathematical integer, then the result is the same as the argument.If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.

    Parameters:

    a - a doubl e val ue.Returns:

    t he cl osest f l oat i ng- poi nt val ue t o a t hat i s equal t o a mat hemat i cal i nt eger .

    atan2

    publ i c st at i c doubl e at an2( doubl e y, doubl e x)

    Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta). This methodcomputes the phase theta by computing an arc tangent of y/ x in the range of -pi to pi. Special cases:

    If either argument is NaN, then the result is NaN.If the first argument is positive zero and the second argument is positive, or the first argument is positive and finite andthe second argument is positive infinity, then the result is positive zero.

    converted by Web2PDFConvert.com

  • If the first argument is negative zero and the second argument is positive, or the first argument is negative and finite andthe second argument is positive infinity, then the result is negative zero.If the first argument is positive zero and the second argument is negative, or the first argument is positive and finite andthe second argument is negative infinity, then the result is the doubl e value closest to pi.If the first argument is negative zero and the second argument is negative, or the first argument is negative and finiteand the second argument is negative infinity, then the result is the doubl e value closest to -pi.If the first argument is positive and the second argument is positive zero or negative zero, or the first argument ispositive infinity and the second argument is finite, then the result is the doubl e value closest to pi/2.If the first argument is negative and the second argument is positive zero or negative zero, or the first argument isnegative infinity and the second argument is finite, then the result is the doubl e value closest to -pi/2.If both arguments are positive infinity, then the result is the doubl e value closest to pi/4.If the first argument is positive infinity and the second argument is negative infinity, then the result is the doubl e valueclosest to 3*pi/4.If the first argument is negative infinity and the second argument is positive infinity, then the result is the doubl e valueclosest to -pi/4.If both arguments are negative infinity, then the result is the doubl e value closest to -3*pi/4.

    The computed result must be within 2 ulps of the exact result. Results must be semi-monotonic.

    Parameters:

    y - t he ordi nat e coordi nat e

    x - t he absci ssa coordi nat eReturns:

    t he t het a component of t he poi nt ( r , t het a) i n pol ar coordi nat es t hat cor responds t o t he poi nt ( x, y) i nCar t esi an coordi nat es.

    pow

    publ i c st at i c doubl e pow( doubl e a, doubl e b)

    Returns the value of the first argument raised to the power of the second argument. Special cases:If the second argument is positive or negative zero, then the result is 1.0.If the second argument is 1.0, then the result is the same as the first argument.If the second argument is NaN, then the result is NaN.If the first argument is NaN and the second argument is nonzero, then the result is NaN.If

    the absolute value of the first argument is greater than 1 and the second argument is positive infinity, orthe absolute value of the first argument is less than 1 and the second argument is negative infinity,

    then the result is positive infinity.If

    the absolute value of the first argument is greater than 1 and the second argument is negative infinity, orthe absolute value of the first argument is less than 1 and the second argument is positive infinity,

    then the result is positive zero.If the absolute value of the first argument equals 1 and the second argument is infinite, then the result is NaN.If

    the first argument is positive zero and the second argument is greater than zero, orthe first argument is positive infinity and the second argument is less than zero,

    then the result is positive zero.If

    the first argument is positive zero and the second argument is less than zero, orthe first argument is positive infinity and the second argument is greater than zero,

    then the result is positive infinity.If

    the first argument is negative zero and the second argument is greater than zero but not a finite odd integer, orthe first argument is negative infinity and the second argument is less than zero but not a finite odd integer,

    then the result is positive zero.If

    the first argument is negative zero and the second argument is a positive finite odd integer, orthe first argument is negative infinity and the second argument is a negative finite odd integer,

    then the result is negative zero.If

    the first argument is negative zero and the second argument is less than zero but not a finite odd integer, orthe first argument is negative infinity and the second argument is greater than zero but not a finite odd integer,

    then the result is positive infinity.If

    the first argument is negative zero and the second argument is a negative finite odd integer, orthe first argument is negative infinity and the second argument is a positive finite odd integer,

    then the result is negative infinity.If the first argument is finite and less than zero

    converted by Web2PDFConvert.com

  • if the second argument is a finite even integer, the result is equal to the result of raising the absolute value of thefirst argument to the power of the second argumentif the second argument is a finite odd integer, the result is equal to the negative of the result of raising the absolutevalue of the first argument to the power of the second argumentif the second argument is finite and not an integer, then the result is NaN.

    If both arguments are integers, then the result is exactly equal to the mathematical result of raising the first argument tothe power of the second argument if that result can in fact be represented exactly as a doubl e value.

    (In the foregoing descriptions, a floating-point value is considered to be an integer if and only if it is finite and a fixed point ofthe method cei l or, equivalently, a fixed point of the method f l oor . A value is a fixed point of a one-argument method if andonly if the result of applying the method to the value is equal to the value.)

    The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.

    Parameters:

    a - t he base.

    b - t he exponent .Returns:

    t he val ue ab.

    round

    publ i c st at i c i nt r ound( f l oat a)

    Returns the closest i nt to the argument, with ties rounding to positive infinity.

    Special cases:

    If the argument is NaN, the result is 0.If the argument is negative infinity or any value less than or equal to the value of I nt eger . MI N_VALUE, the result is equal tothe value of I nt eger . MI N_VALUE.If the argument is positive infinity or any value greater than or equal to the value of I nt eger . MAX_VALUE, the result isequal to the value of I nt eger . MAX_VALUE.

    Parameters:

    a - a f l oat i ng- poi nt val ue t o be rounded t o an i nt eger .Returns:

    t he val ue of t he argument rounded t o t he nearest i nt val ue.See Also:

    I nt eger . MAX_VALUE, I nt eger . MI N_VALUE

    round

    publ i c st at i c l ong round( doubl e a)

    Returns the closest l ong to the argument, with ties rounding to positive infinity.

    Special cases:

    If the argument is NaN, the result is 0.If the argument is negative infinity or any value less than or equal to the value of Long. MI N_VALUE, the result is equal tothe value of Long. MI N_VALUE.If the argument is positive infinity or any value greater than or equal to the value of Long. MAX_VALUE, the result is equal tothe value of Long. MAX_VALUE.

    Parameters:

    a - a f l oat i ng- poi nt val ue t o be rounded t o a l ong.Returns:

    t he val ue of t he argument rounded t o t he nearest l ong val ue.See Also:

    Long. MAX_VALUE, Long. MI N_VALUE

    random

    publ i c st at i c doubl e random( )

    converted by Web2PDFConvert.com

  • Returns a doubl e value with a positive sign, greater than or equal to 0. 0 and less than 1. 0. Returned values are chosenpseudorandomly with (approximately) uniform distribution from that range.

    When this method is first called, it creates a single new pseudorandom-number generator, exactly as if by the expression

    new j ava. ut i l . Random( )

    This new pseudorandom-number generator is used thereafter for all calls to this method and is used nowhere else.

    This method is properly synchronized to allow correct use by more than one thread. However, if many threads need to generatepseudorandom numbers at a great rate, it may reduce contention for each thread to have its own pseudorandom-numbergenerator.

    Returns:

    a pseudorandom doubl e great er t han or equal t o 0. 0 and l ess t han 1. 0.See Also:

    Random. next Doubl e( )

    addExact

    publ i c st at i c i nt addExact ( i nt x, i nt y)

    Returns the sum of its arguments, throwing an exception if the result overflows an i nt .

    Parameters:

    x - t he f i r st val ue

    y - t he second val ueReturns:

    t he resul tThrows:

    Ar i t hmet i cExcept i on - i f t he resul t over f l ows an i ntSince:

    1. 8

    addExact

    publ i c st at i c l ong addExact ( l ong x, l ong y)

    Returns the sum of its arguments, throwing an exception if the result overflows a l ong.

    Parameters:

    x - t he f i r st val ue

    y - t he second val ueReturns:

    t he resul tThrows:

    Ar i t hmet i cExcept i on - i f t he resul t over f l ows a l ongSince:

    1. 8

    subtractExact

    publ i c st at i c i nt subt ract Exact ( i nt x, i nt y)

    Returns the difference of the arguments, throwing an exception if the result overflows an i nt .

    Parameters:

    x - t he f i r st val ue

    y - t he second val ue t o subt ract f r om t he f i r stReturns:

    converted by Web2PDFConvert.com

  • t he resul tThrows:

    Ar i t hmet i cExcept i on - i f t he resul t over f l ows an i ntSince:

    1. 8

    subtractExact

    publ i c st at i c l ong subt ract Exact ( l ong x, l ong y)

    Returns the difference of the arguments, throwing an exception if the result overflows a l ong.

    Parameters:

    x - t he f i r st val ue

    y - t he second val ue t o subt ract f r om t he f i r stReturns:

    t he resul tThrows:

    Ar i t hmet i cExcept i on - i f t he resul t over f l ows a l ongSince:

    1. 8

    multiplyExact

    publ i c st at i c i nt mul t i pl yExact ( i nt x, i nt y)

    Returns the product of the arguments, throwing an exception if the result overflows an i nt .

    Parameters:

    x - t he f i r st val ue

    y - t he second val ueReturns:

    t he resul tThrows:

    Ar i t hmet i cExcept i on - i f t he resul t over f l ows an i ntSince:

    1. 8

    multiplyExact

    publ i c st at i c l ong mul t i pl yExact ( l ong x, l ong y)

    Returns the product of the arguments, throwing an exception if the result overflows a l ong.

    Parameters:

    x - t he f i r st val ue

    y - t he second val ueReturns:

    t he resul tThrows:

    Ar i t hmet i cExcept i on - i f t he resul t over f l ows a l ongSince:

    1. 8

    incrementExact

    converted by Web2PDFConvert.com

  • publ i c st at i c i nt i ncrement Exact ( i nt a)

    Returns the argument incremented by one, throwing an exception if the result overflows an i nt .

    Parameters:

    a - t he val ue t o i ncrementReturns:

    t he resul tThrows:

    Ar i t hmet i cExcept i on - i f t he resul t over f l ows an i ntSince:

    1. 8

    incrementExact

    publ i c st at i c l ong i ncrement Exact ( l ong a)

    Returns the argument incremented by one, throwing an exception if the result overflows a l ong.

    Parameters:

    a - t he val ue t o i ncrementReturns:

    t he resul tThrows:

    Ar i t hmet i cExcept i on - i f t he resul t over f l ows a l ongSince:

    1. 8

    decrementExact

    publ i c st at i c i nt decrement Exact ( i nt a)

    Returns the argument decremented by one, throwing an exception if the result overflows an i nt .

    Parameters:

    a - t he val ue t o decrementReturns:

    t he resul tThrows:

    Ar i t hmet i cExcept i on - i f t he resul t over f l ows an i ntSince:

    1. 8

    decrementExact

    publ i c st at i c l ong decrement Exact ( l ong a)

    Returns the argument decremented by one, throwing an exception if the result overflows a l ong.

    Parameters:

    a - t he val ue t o decrementReturns:

    t he resul tThrows:

    Ar i t hmet i cExcept i on - i f t he resul t over f l ows a l ongSince:

    1. 8

    negateExact

    converted by Web2PDFConvert.com

  • publ i c st at i c i nt negat eExact ( i nt a)

    Returns the negation of the argument, throwing an exception if the result overflows an i nt .

    Parameters:

    a - t he val ue t o negat eReturns:

    t he resul tThrows:

    Ar i t hmet i cExcept i on - i f t he resul t over f l ows an i ntSince:

    1. 8

    negateExact

    publ i c st at i c l ong negat eExact ( l ong a)

    Returns the negation of the argument, throwing an exception if the result overflows a l ong.

    Parameters:

    a - t he val ue t o negat eReturns:

    t he resul tThrows:

    Ar i t hmet i cExcept i on - i f t he resul t over f l ows a l ongSince:

    1. 8

    toIntExact

    publ i c st at i c i nt t oI nt Exact ( l ong val ue)

    Returns the value of the l ong argument; throwing an exception if the value overflows an i nt .

    Parameters:

    val ue - t he l ong val ueReturns:

    t he argument as an i ntThrows:

    Ar i t hmet i cExcept i on - i f t he argument over f l ows an i ntSince:

    1. 8

    floorDiv

    publ i c st at i c i nt f l oorDi v( i nt x, i nt y)

    Returns the largest (closest to positive infinity) i nt value that is less than or equal to the algebraic quotient. There is onespecial case, if the dividend is the Integer.MIN_VALUE and the divisor is - 1, then integer overflow occurs and the result is equalto the I nt eger . MI N_VALUE.

    Normal integer division operates under the round to zero rounding mode (truncation). This operation instead acts under theround toward negative infinity (floor) rounding mode. The floor rounding mode gives different results than truncation when theexact result is negative.

    If the signs of the arguments are the same, the results of f l oorDi v and the / operator are the same. For example, f l oorDi v( 4, 3) == 1 and ( 4 / 3) == 1.If the signs of the arguments are different, the quotient is negative and f l oorDi v returns the integer less than or equal tothe quotient and the / operator returns the integer closest to zero.For example, f l oorDi v( - 4, 3) == - 2, whereas ( - 4 / 3) == - 1.

    Parameters:

    x - t he di vi dend

    converted by Web2PDFConvert.com

  • y - t he di vi sorReturns:

    t he l argest ( cl osest t o posi t i ve i nf i ni t y) i nt val ue t hat i s l ess t han or equal t o t he al gebrai c quot i ent .Throws:

    Ar i t hmet i cExcept i on - i f t he di vi sor y i s zeroSince:

    1. 8See Also:

    f l oorMod( i nt , i nt ) , f l oor ( doubl e)

    floorDiv

    publ i c st at i c l ong f l oorDi v( l ong x, l ong y)

    Returns the largest (closest to positive infinity) l ong value that is less than or equal to the algebraic quotient. There is onespecial case, if the dividend is the Long.MIN_VALUE and the divisor is - 1, then integer overflow occurs and the result is equalto the Long. MI N_VALUE.

    Normal integer division operates under the round to zero rounding mode (truncation). This operation instead acts under theround toward negative infinity (floor) rounding mode. The floor rounding mode gives different results than truncation when theexact result is negative.

    For examples, see f l oorDi v( i nt , i nt ) .

    Parameters:

    x - t he di vi dend

    y - t he di vi sorReturns:

    t he l argest ( cl osest t o posi t i ve i nf i ni t y) l ong val ue t hat i s l ess t han or equal t o t he al gebrai c quot i ent .Throws:

    Ar i t hmet i cExcept i on - i f t he di vi sor y i s zeroSince:

    1. 8See Also:

    f l oorMod( l ong, l ong) , f l oor ( doubl e)

    floorMod

    publ i c st at i c i nt f l oorMod( i nt x, i nt y)

    Returns the floor modulus of the i nt arguments.

    The floor modulus is x - ( f l oorDi v( x, y) * y) , has the same sign as the divisor y, and is in the range of - abs( y) < r