Mathematical Functiins
1. Math.sqrt ()- returns the square root of a positie number. It returns a
double type ialue.
double n=Math.sqrt (25.0); output n=5.0
double n=Math.sqrt (1.44); output n=1.2
double n=Math.sqrt (-4.0); output n=NaN
2. Math.cbrt() – returns the cube root of a positie or negatie number. It
returns a double type ialue.
double n= Math.cbrt(125.0) ; output n= 5.0
double n=Math.cbrt(-27.0); output n= -3.0
3. Math.min ()- returns the minimum of two number. It returns integer or
double type ialue depends upon the arguments it takes.
double n=Math.min(25.0,34.0); output n=25.0
int n=Math.min (4,6); output n=4
double n=Math.min(-4.2,-3.4); output n=-4.2
4. Math.max ()- returns the maximum of two number. It returns integer
or double type ialue depends upon the arguments it takes.
double n=Math.max(25.0,34.0); output n=34.0
int n=Math.max(4,6); output n=6
double n=Math.max(-4.2,-3.4); output n=-3.4
5. Math.pow()- returns the ialue when a specifed base is raised to a giien
power. It returns a double type ialue.
double n=Math. pow (2.0,3.0); output n=8.0
double n=Math.pow (25.0,1/2); output n=5.0
double n=Math.pow (25.0,-1/2); output n=0.2
6. Math. abs()- returns the absolute ialue means number without sign. It
returns integer or double type ialue depends upon the arguments.
double n=Math.abs (1.44); output n=1.44
int n=Math.abs (-4); output n=4
7. Math.log ()- returns the natural log ialue. It returns a double type ialue.
double n=Math.log (6.25); output n=1.83
8. Math.round ()- returns the ialue in its rounded of form . It returns a
double type ialue. If the fractonal part of the number is below 0.5, it
returns the same integer ialue, otherwise it returns the next integer
ialue in double data type.
double n=Math. round(0.49); output n=0.0
double n=Math.round(0.5); output n=1
double n=Math.round (-4.50); output n=-4
double n=Math.round (-4.501); output n=-5
double n=Math.round (4.50); output n=5
9. Math.foor()- returns the ialue in its rounded of form . It returns a
double type ialue. It returns a number by rounding it down to the
nearest integer.
double n=Math. foor(0.49); output n=0.0
double n=Math.foor(0.5); output n=0.0
double n=Math.foor (-4.50); output n=-5
double n=Math.foor (-4.7501); output n=-5
double n=Math.foor (4.50); output n=4
10.Math.ceil()- returns the ialue in its rounded of form . It returns a double
type ialue. It returns a number by rounding it next higher integer.
double n=Math. ceil(0.49); output n=1.0
double n=Math. ceil(-0.49); output n=-0.0
double n=Math.ceil (-4.50); output n=-4
double n=Math.ceil (-4.7501); output n=-4
double n=Math.ceil (4.50); output n=5
11.Math.rint( )- returns the integer part of the fractonal number when the
fractonal part is less or equal to 0.5 and it returns the next higher ialue
for more than 0.5 in double data type.
double d= Math.rint(6.45) output d = 6.0
double d= Math.rint(6.87) output d = 7.0
double d= Math.rint(6.5) output d = 6.0
double d= Math.rint(-6.45) output d =- 6.0
double d= Math.rint(-6.5) output d = -6.0
double d= Math.rint(-6.54) output d = -7.0
12.Math.random ( ) - returns a random number between 0 and 1. It returns
a double data type.
double n = Math.random();
13.Math.sin ( ) – returns the sin ialues respectiely of a giien angle (in
radians )as an argument.
double n= Math.sin( x);
coniersion from degree to radian
180 degree = ∏ radian =22/7 radian
So Radian = (22/(7*180))*degree
Let a = 30;
X= (22/7*180))*a
14.Math.asin ( ) – returns the angle in degrees.
Degree = (radian*7*180)/22;
15.Math. exp ( ) –returns the exponental ialue i.e eX
double n = Math.exp(6.25 ) output n = 518.0128