Math Functions for use in Java
Some useful
terms for proceeding further.
Program :
Program is a set of Instructions given to a computer to perform a specific
task.
Package :
Package is a collection of classes to perform various functions.
In Java
every package has a name and it can be included within a program by using the
keyword “import”.
For now let us consider the following functions
in the Math package of Java. Note that many of the Math functions are called
automatically by the system(by default) to perform the desired task.
(1) Math.sqrt(): This function is used to
find the square root of the given number.
Ex: num=Math.sqrt(9);
So the value of
the num will be 3.
(2) Math.pow(): This function is used to
find the power raised to a specified base.
Ex: num=Math.pow(2,3);
So the value of
the num is 2^3=8
The
above example is just to show how we use the math functions. We will explore
more math functions in further posts.
In next post we will cover the use of Classes in Java and also the creation and use of objects in Java.
Bye! Keep visiting.


No comments:
Post a Comment