Mathematical Library Functions
• Java has many built-in packages like [Link], [Link], [Link] etc.
• The [Link] package is imported by default by the java compiler. This
package contains many classes that are required for designing a program.
• The Math class of the [Link] package contains functions / methods for
performing mathematical and trigonometrical functions.
Note : you can invoke the methods of Math class with the class name
directly without creating an object for the class.
SNO FUNCTION SYNTAX WITH DESCRIPTION
( EXAMPLE )
1. [Link](); Syntax: Returns the square root of
[Link](n); the given number.
Eg:- It returns a double datatype
[Link](4); value.
2.0
2. [Link](); Syntax: Returns cube root of the
[Link](n); number.
Eg:- It returns a double datatype
[Link](125); value.
5.0
3. [Link](); Syntax: Returns the value of the first
[Link](a,b); number raised to the power
Eg:- of the second number.
[Link](10,2); (first number is base and
100.0 second number is exponent)
It returns a double datatype
value.
4. [Link](); Syntax: Returns the largest of the
[Link](a,b); two given numbers.
Eg:- The return type depends
[Link](106,104); upon the datatype of given
106 numbers.
[Link](-10, -7);
-7
5. [Link](); Syntax: Returns the smallest of the
[Link](a,b); two given numbers.
Eg:- The return type depends
[Link](- 7.5,-10.6); upon the datatype of the
- 10.6 given numbers.
6. [Link](); Syntax: Returns the absolute value
[Link](n); (ignoring the sign) of the
Eg:- given number.
[Link](-10.6); The return type depends
10.6 upon the datatype of the
value given.
7. [Link](); Syntax: Return the closest higher
[Link](a); integer value( >=).
Eg:- It returns a double type
[Link] (10.6); value.
11.0
[Link](- 14.56)
-14.0
( - 14.56 is between
- 14 and - 15
- 14 is the closest
higher integer value)
8. [Link](); Syntax: Return the closest lower
[Link](a); integer value(<=).
Eg:- It returns a double datatype
[Link] (10.6); value.
10.0
[Link](-14.56);
-15.0
9. [Link](); Syntax: Returns the rounded value
[Link](a); of the given number.
Eg:- It returns an integer
[Link](10.6); datatype value.
11
x------------------------------------------------------x