0% found this document useful (0 votes)
12 views14 pages

Java Math Functions Overview

The document provides an overview of various Java mathematical functions available in the Math package, including methods for calculating square roots, minimum and maximum values, powers, logarithms, absolute values, rounding, and trigonometric functions. Each function is accompanied by its syntax and examples demonstrating its usage. Additionally, it explains how to generate random numbers within specified ranges using the Math.random() function.

Uploaded by

shopscsj
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views14 pages

Java Math Functions Overview

The document provides an overview of various Java mathematical functions available in the Math package, including methods for calculating square roots, minimum and maximum values, powers, logarithms, absolute values, rounding, and trigonometric functions. Each function is accompanied by its syntax and examples demonstrating its usage. Additionally, it explains how to generate random numbers within specified ranges using the Math.random() function.

Uploaded by

shopscsj
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Packages for Mathematical

Functions
Nilay Bhatia X-D
[Link]( )
• This function is used to find the square
root of a positive number.
• It returns a double type value.
• Syntax: <Return Data type><variable> =
[Link] (Positive number);
• E.g. double n=[Link](4.0); 2.0
double m=[Link](6.25); 2.5
[Link]( )
• This function returns minimum of two numbers.
The return value depends on the values used as
the arguments of the function.
• Syntax: <Return Data type><variable> =
[Link] (argument 1, argument 2);
• E.g. int n= [Link](4,6) 4
double n= [Link](4.6,2.8) 2.8
[Link]( )
• This function returns maximum of two numbers.
The return value depends on the values used as
the arguments of the function.
• Syntax: <Return Data type><variable> =
[Link] (argument 1, argument 2);
• E.g. int n= [Link](34,7) 34
double n= [Link](4.6,2.8) 4.6
[Link]( )

• This function is used to find the value of a


number raised to a power.
• Syntax: <Return Data type*><variable> =
[Link] (base value, power value);
• E.g. double n = [Link](2.0,3.0) 8
double m=[Link](5.0,-2.0) 0.04

• *Please note that return type of [Link] is always


double.
[Link]( )
• This function returns natural logarithmic
value of a given argument.
• It always returns a double type value.
• Syntax: <Return Data type><variable> =
[Link](Positive number);
• E.g. double n=[Link](100.0); 2.0
double m=[Link](6.25); 1.8325
[Link]
• It returns the positive value of a number.
• The return value depends on the values
used as the argument of the function.
• Syntax: <Return Data type><variable> =
[Link](number);
• E.g. int n= [Link](25) 25
double n= [Link](-4.6) 4.6
[Link]
• This function will round off the number.
• It always returns in double data type.
• Syntax: <Return Data type><variable> =
[Link](number);
• E.g. double n= [Link](2.3) 2.0
double m= [Link](4.5) 5.0
double d= [Link](-8.92) -9.0
[Link]( ) [Link]
This function is used to round the This function is used to round the
given number down to the nearest value to the next higher integer.
integer.
The outcome is always a double type It returns a double type value.
number.
Syntax: <Return Data type><variable> Syntax: <Return Data type><variable>
= [Link](number); = [Link](number);

E.g. E.g.
double n= [Link](6.25) 6.0 double n= [Link](6.25) 7.0
double m= [Link](4.9) 4.0 double m= [Link](4.9) 5.0

double j = [Link](-6.25) -7 double j = [Link](-6.25) -6

double d= [Link](-6.85) -7.0 double d= [Link](-6.85) -6.0


[Link](), [Link](), [Link]()
• These are trigonometrical functions.
• These are used to find the sine, cosine,
and tangent of an angle. The angle is the
input and the ratio is the output.
• The return data type is double.
• Syntax: <Return Data type><variable> =
[Link](value in radians);
• E.g. double n=[Link](0.52359); 0.5
double m=[Link] (1.5707); 0.0
[Link](), [Link](), [Link]()
• These are arc functions (also known as
inverse functions).
• Each function provides angle corresponding
to the given value in sin, cos or tan. . The
value is the input and the angle is the output.
• Syntax: <Return Data type><variable> =
[Link](value);
• E.g. double n=[Link](0.5); 0.523598776
double m=[Link] (0.0); 1.57079633
[Link]
• This function returns a random number
between 0 and 1.
• It returns a double type value.
• Syntax: <Return Data type><variable> =
[Link]();
• E.g. double n=[Link]();
Modifications with [Link]() function

• To generate a number between 0 to n :-


(int)([Link] () *n)
E.g. (int)([Link]()*5);
• To generate a number between a
custom range:-
• (int)([Link] () *n) +m) lower limit

higher limit
• PPT by:
• Nilay
Bhatia

You might also like