Home   |   About   |   Terms   |   Contact    
Read & Learn
 

Mathematical Functions And Constants in Java

Java

☯ All Java Articles     ☯ All Articles


A new product.






Popular Google Pages:




This article is regarding Mathematical Functions And Constants in Java.
Last updated on: .



◕ Mathematical Functions And Constants in Java.

- We need mathematical functions in your programs.
Java provides a range of methods that support mathematical functions as part of the standard library.
All these are available in our program automatically.

These standard libraries are stored in the java.lang.
We can access this java.lang easily.

These mathematical functions are present in the Math class as static methods.
So to use a particular function we just write Math and the name of the method separated by a period.

The examples are given bellow:
■ Math.PI
This gives the value of pie.

■ Math.cbrt(argument)
This gives the cube root of the argument.



◕ Other mathematical functions are given bellow.

■ Math.abs(argument)
This calculates the absolute value of the argument value.
Argument Type: int, long, float or double.
Result Type: The same type as the argument.


■ Math.max(first_Argument,second_Argument)
Returns the larger value between the two arguments. But the arguments should be same type.
Argument Type: int, long, float or double.
Result Type: The same type as the arguments.


■ Math.min(first_Argument,second_Argument)
Returns the smaller value between the two arguments. But the arguments should be same type.
Argument Type: int, long, float, or double.
Result Type: The same type as the arguments.


■ Math.ceil(Argument)
Returns the smallest integer that is greater than or equal to the Argument value.
Argument Type: double.
Result Type: double.


■ Math.floor(Argument)
Returns the largest integer that is less than or equal to the argument value.
Argument Type: double.
Result Type: double.


■ Math.round(Argument)
Calculates the nearest integer to the argument value.
Argument Type: float or double.
Result Type:
Type int for a float argument.
Type long for a double argument.

■ Math.rint(Argument)
Calculates the nearest integer to the argument value.
Argument Type: double.
Result Type: double.


■ Math.sqrt(Argument)
Calculates the square root of the argument.
Argument Type: double.
Result Type: double.


■ Math.cbrt(Argument)
Calculates the cube root of the argument.
Argument Type: double.
Result Type: double.


■ Math.pow(first_Argument,second_Argument)
Calculates the first argument to the power of the second argument.
Argument Type: Both double.
Result Type: double.


■ Math.hypot( first_Argument,second_Argument)
Calculates the square root of (squre of first_Argument + square of second_Argument).
Argument Type: Both double.
Result Type: double.


■ Math.exp(Argument)
Calculates e to the power of the argument.
Argument Type: double.
Result Type: double.


■ Math.log(Argument)
Calculates the natural logarithm (base e) of the argument.
Argument Type: double.
Result Type: double.


■ Math.log1p(Argument)
Calculates the natural logarithm (base e) of argument + 1.
Argument Type: double.
Result Type: double.


■ Math.log10(Argument)
Calculates the logarithm ( base 10 ) of the argument.
Argument Type: double.
Result Type: double.


■ Math.random()
Returns a pseudo-random number greater than or equal to 0.0 and less than 1.0.
Result Type: double.


■ Math.sin(Argument)
Calculates the sine of the argument.
Argument Type: double in radians.
Result Type: double.


■ Math.cos(Argument)
Calculates the cosine of the argument.
Argument Type: double in radians.
Result Type: double.


■ Math.tan(Argument)
Calculates the tangent of the argument.
Argument Type: double in radians.
Result Type: double.


■ Math.asin(Argument)
Returns arc sine of the argument.
Argument Type: double.
Result Type: double in radians with values from -π/2 to π/2.


■ Math.acos(Argument)
Calculates the arc cosine of the argument.
Argument Type: double.
Result Type: double in radians, with values from 0.0 to π.


■ Math.atan(Argument)
Calculates the arc tangent of the argument.
Argument Type: double.
Result Type: double in radians with values from -π/2 to π/2.


■ Math.atan2(first_Argument,second_Argument)
Calculates the arc tangent of first_Argument/second_Argument.
Argument Type: Both double.
Result Type: double in radians with values from -π to π.




Related Java articles:
What is Java? Where we can apply Java?
Why Java is a Machine Independent Program? What is Machine Independent Program?
Root Directory of Java
How to Compile and run a Java Program?
What is .class file in Java?
What is variable in a program?
What is identifier in Java?
Integer data types in Java?
What is Primitive Types in Java?
How to declare constant variables in Java?
Why should we declare the initial value of a variable in Java?
Use of Underscores to write an integer in Java





Popular Google Pages:





Top of the page

Amazon & Flipkart Special Products

   


Top of the page