Download presentation
Presentation is loading. Please wait.
Published byAnnice Garrison Modified over 8 years ago
1
CSE 110: Programming Language I Afroza Sultana afroza@bracuniversity.ac.bd UB 1230
2
Math Class Very useful. Provides many methods in a pre-built class. The following are available in the Math class Trigonometry functions (input in radian instead of in degree): sin, cos, tan, acos, atan, asin
3
Exponent Methods exp – raise e to a power sqrt – returns the square root pow – raise a number to a power log – natural log of a number
4
Rounding in Math Class ceil – round up to nearest integer floor – round down to nearest integer
5
Helpful Math random – Returns a random number greater than or equal to 0.0 and less than 1.0 abs – return absolute value of a number min – return minimum of two numbers max – return max of two numbers
6
Mathematical Library Functions In MathematicsIn Java | y | or absolute value of yMath.abs(y) xyxy Math.pow(x, y) square root of xEither try, Math.sqrt(x) or try, Math.pow(x, 1.0/2) cube root of xMath.cbrt(x) exex Math.exp(x) log e (x)Math.log(x) log 10 (x)Math.log10(x) log b (x)Either try, Math.log(x) / Math.log(b) or try, Math.log10(x) / Math.log10(b) in radian sin xMath.sin(x) in degree sin xEither try, Math.sin( Math.toRadians(x) ) or try, Math.sin(x * Math.PI/180) cos xMath.cos(x * Math.PI/180) cosec x1 / Math.cos(x * Math.PI/180) tan yMath.tan(y * Math.PI/180) here x and y are of type double. You can find out more from http://download-llnw.oracle.com/javase/6/docs/api/java/lang/Math.html
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.