You are on page 1of 8

Date

Page

Math library Meth.ds


Pocakage- A pacakace is àà colechian sf clases
and interfaLes having similar pn funetionality.
Ea-java. util, java.lang ava.io , ete.
java lanq is the delault paackage.
Methods
within
I4 is aà set of code or statemnents
RLAR à pair of braces to perform a task
Gr gperation. Methods are at various typesi
upes
DLorary Methods - Ihe methods awhich are already.
defined Rre caled Library Method.
ser Defined Methods - Ihe methads which are
cle fined by the programmer accorcing to the.
needs Are known as User Dehined Methods.

Ma th
Math is aa class defined in java.lang package
and it pcovides various mathematcal functions.
nathabsC) Date

Poge

Return Type function Name

int long
arguments
oAbsCint Jint
|Oeseriptisn
lt take one
tloat, double labsllong ) torg argument
abs(float}tot)
abs Ldouble
and returng
doeeabsalute valuE
lgnares the
Siqn ândreturns
retag
the posiive
value
Eg.-ME’ l-5
J.E.’
Mathalos
2y int max intgint)
Long max (long,Lon) arguments and
loat |m-x Lloak ,float) returns the
double
maxldoubk,doubemaximum
|value.
Eg-Math.maxln,t5)
Ofp n.0
-Math.maxl-l4,-5)
o/h -13
Sangamo
Date

Page

Jint min Cint,int)


Lonq min Llong , long
float min(float,float)
double minC double , dauble)

\t_ takes twa arquments And qivcs the


minimum value.
Eq - Math. minl-L,)
-Math.min (n,3.5)

Sqrt (dauble)
It takes one double arqument And returns
Square root ot a number.
Eq - Math sart l25)
olp 35.0
Math. sat-16)
3 Runtime Error
Date
Page

double cortldouble)
lt takes double_áraument and returns cube
root of a numher.
Ea - MAth.cbrt Cob4)
- Math. cbrt (-8)
olp -2.0

douloe - ceil (dau lole

Makes one double arqument Aand roLInds


4up the value and then returns it.
Eg - Math. ceil 7.3)
Olp 8.0
- Math.ceil(a.g)

- Math.ceilC-16.8)
:-15.0
olp
Y double floor Cdouble)

A takes one double arqument and rounds


down the value
Sanqano
Date

Page

Eq- Math. floor (-1.3)


Eg olp: -18.0
- Math. loor I7.o)
olp: 17.0

powdeukhle , double)
t takes two double arquments and returns first
arqument etn raised to the power of the
second arqument.
Eg- Math.pow (Msth.maxlrn,4), Math.min (I,3))
- Math. pow(64,o.5)
9.0
-Math.pow L64,) Nath-pow&4,0)

9)dauble -rintldloublk)

t returns even deimal value if it is equally


cJose otherwise it raunds of# the value.
be- Math. rint (115) - Mathrint(&.501)
Math rint (8.5)
o/p 8.0
Date

Page

found fdouble>
1o) int YOundlloat)
long round (double)
H takes one
arqument and rounds off the
Value. Till one decimal place..
Eq-
Math.round(.5) - Math. round(-1s.3)
28
- Math. round (8.44) - Math. ound (-o.5)
O/p &

doulale - exp (double)


Htakes ne douhlk argument and returns'e!
raised to the po Wer at the argurm ent.

WriteL java expression for lem

Math.abs CMath.exp (4*)tmta)

Math.pow
Sangam (Laty),2)la)
Date

Page

Java expression tor àb +

double.
tong Log Ldouble)
This funcbon retunns the natural tetre
laqucithmic value.
Eg- Math.log (1o)
a double randomnC)

returns a random value qreater th-n or


equal to 0.0 and less th an l.0

Q Wite a statement to qenerate random numbers


trom the range of 0.0 to \00.0

System.out.printn(Mathurandom ()* 1co)


eath rbund (Math.candom )+45)
Y6.0
Date

Page

1double Sin Cdouble)


doub le Cos Cdouble)
cdouble tân Cdoulble)

&S lt retums the sin and tangent value


of _an angle in radiance.
Eg- Math. sin (90)
AVariable - Math. PT
(3.14)

JangaU

You might also like