Val James Porcare 1 CpE 1 Commonly Used Methods of the java.lang.Math class The operators +, -, *, /, and % give us a way to add, subtract, multiply, divide, and "mod" values together in java, but having to implement some of the more sophisticated functions of mathematics (like the square root or sine functions) with only these operators would be challenging indeed! As such, the java.lang.Math class provides us access to many of these functions. The table below lists some of the more common among these. (There are more than just these in java.lang.Math, however -one should consult the java API for the whole list.) Method Returns Math.sqrt(x) x−−√x Math.pow(x,y) xyxy Math.sin(x) sinxsinx Math.cos(x) cosxcosx Math.tan(x) tanxtanx Math.asin(x) sin−1xsin−1x Math.acos(x) cos−1xcos−1x Math.atan(x) tan−1xtan−1x Math.exp(x) exex Math.log(x) lnxlnx Math.log10(x) log10xlog10x Math.round(x) the closest integer to x, as athe closest integer to x, as a long Math.abs(x) |x||x| Math.max(x,y) The maximum of the two valuesThe Math.min(x,y) The minimum of the two valuesThe maximum of the two values minimum of the two values Additionally, the java.lang.Math class provides two very frequently used constants that you might recognize: Constant Type Value Math.PI double 3.14159265358979323846 Math.E double 2.7182818284590452354