The Java Math Library provides various Functions and Constants / Properties. These math functions allow us to perform basic mathematical operations like square root, cube root, logarithmic, and trigonometric functions.
Unlike other global objects, Properties and Functions inside the Java math library class are static. So, we can access the properties as Math.PI and functions as Math.abs(number).
Java Math Library Properties
The following table will show the list of Properties or Constants available in the Java Math library
Modifier | Properties | Description |
---|---|---|
static double | Math.E | It will return the Euler’s Number E, which is approximately equal to 2.71828 |
static double | Math.PI | This property will return the Pie Value, which is approximately equal to 3.14 |
Java Math Library Functions
The following table will show the list of Functions available in Java Math Library.
Modifier Type | Functions | Description |
---|---|---|
static double | abs(double x) | It will return the Absolute value of a Double value |
static float | abs(float x) | This Java math library function will return the Absolute value of a Float value |
static int | abs(int x) | It will return the Absolute value of an Integer |
static long | abs(long x) | It will return the Absolute value of a Long value |
static double | cbrt(double x) | It returns the Cube root of the specified expression or a double value. |
static double | ceil(double x) | This will return the smallest double value. And it is greater than or equal to the specified expression or a double value. |
static double | copySign(double magnitude, double sign) | It is to find the Absolute value of the first argument along with the sign specified in the second argument |
static float | copySign(float magnitude, float sign) | It is to find the Absolute value of the first argument along with the sign specified in the second argument |
static double | floor(double x) | This Java math library function returns the largest integer value. And it is less than or equal to the specified expression or a double value. |
static double | getExponent(double x) | It returns the unbiased exponent used in the representation of double. |
static float | getExponent(float x) | It returns the unbiased exponent used in the representation of float. |
static double | IEEEremainder(double x, double y) | It will calculate the remainder of two arguments prescribed by the IEEE 754 standards and return the value. |
static double | max(double x, double y) | This math function returns the Largest of two double values. |
static float | max(float x, float y) | It is to return the Largest of two float values. |
static int | max(int x, int y) | It is to return the Largest of two int values. |
static long | max(long x, long y) | It is to return the Largest of two long values. |
static double | min(double x, double y) | It is to return the Smallest of two double values. |
static float | min(float x, float y) | It is to return the Smallest of two float values. |
static int | min(int x, int y) | It returns x * 2ScaleFactor rounded as if performed by a single correctly rounded floating point multiplied by a member of the double value set. |
static long | min(long x, long y) | It is to return the Smallest of two long values. |
static double | nextAfter(double start, double direction) | It returns a floating point value that is adjacent to the first argument in the direction of the second argument. |
static float | nextAfter(float start, double direction) | It returns a floating point value that is adjacent to the first argument in the direction of the second argument. |
static double | nextUp(double x) | It returns the adjacent value of the given argument in the direction of positive infinity. |
static float | nextUp(float x) | This Java math library function returns the adjacent value of the given argument in the direction of positive infinity. |
static double | pow(double x, double y) | It is to return the value of the first argument raised to the Power of the second argument |
static double | random() | It returns the double value with a positive sign, and the value will be greater than or equal to 0.0 and less than 1.0 |
static double | rint(double x) | It returns the double value, which is closest to the given argument and equal to a mathematical integer |
static long | round(double x) | It rounds the specified expression or an individual number to the nearest long. |
static int | round(double x) | Round the specified expression or an individual number to the nearest int. |
static double | scalb(double x, int ScaleFactor) | It returns x * 2ScaleFactor rounded as if performed by a single correctly rounded floating-point multiplied by a member of the double value set. |
static float | scalb(float x, int ScaleFactor) | This Java math library function returns x * 2ScaleFactor rounded as if performed by a single correctly rounded floating point multiplied by a member of the float value set. |
static double | signum(double x) | It returns the signum of the given argument. |
static float | signum(float x) | It returns the signum of the given argument. |
static double | sqrt(double x) | This Java math library function is used to find the square root of a specified expression or an individual number |
static double | ulp(double x) | The size of an ulp of the given double argument |
static float | ulp(float x) | The size of an ulp of the given float argument |
Java math library Logarithmic Functions
The following functions are the list of Power and logarithmic functions available in Java Math Library.
Modifier Type | Power and Logarithmic Functions | Description |
---|---|---|
static double | exp(double x) | It returns E raised to the power of double value, Where E is Euler’s number, and it is approximately equal to 2.71828. |
static double | expm1(double x) | It calculates the power of E (Where E is Euler’s number approximately equal to 2.71828) and subtracts one from it. |
static double | log(double x) | Logarithmic value of a given number with base E. |
static double | log10(double x) | Logarithmic value of a given number with base 10. |
static double | log1p(double x) | It returns the natural algorithm of the sum of the arguments and 1. |
Java math library Trigonometric Functions
The following functions are the list of Trigonometric functions available in the Java Math Library.
Modifier Type | Trigonometric Functions | Description |
---|---|---|
static double | acos (double x) | It will return the trigonometric Arc Cosine value of a Given double value |
static double | asin(double x) | This function will return the trigonometric Arc Sine value of a Given double value |
static double | atan(double x) | It will return the trigonometric Arc Tangent value of a Given double value |
static double | atan2(double y, double x) | This Java math library function will return the angle (in radius) from the X-Axis to the specified point (y, x). |
static double | cos(double x) | It will return the trigonometric Cosine value of a Given double value |
static double | hypot(double x, double y) | It will return the sqrt(x² + y²) without intermediate overflow or underflow |
static double | sin(double x) | This sin function will return the trigonometric Sine value of a Given double value |
static double | tan(double x) | It will return the trigonometric Tangent value of a Given double value |
Hyperbolic Functions
The Java Hyperbolic Functions are trigonometric functions that allow performing the following Hyperbolic library functions instead of Circles. The following functions are the list of Hyperbolic functions available in the Java Math Library.
Modifier Type | Hyperbolic Functions | Description |
---|---|---|
static double | cosh(double x) | It will return the trigonometric Hyperbolic Cosine value of a Given double value |
static double | sinh(double x) | This function will return the trigonometric Hyperbolic Sine value of a Given double value |
static double | tanh(double x) | It will return the trigonometric Hyperbolic Tangent value of a Given double value. |
Angular Functions
The following functions are the list of Angular functions available in the Java Math Library.
Modifier Type | Angular Functions | Description |
---|---|---|
static double | toDegrees(double x) | It will convert the specified Radians angle to an equivalent angle measured in Degrees. |
static double | toRadians(double x) | This angular function will convert the specified Degrees angle to the equivalent angle measured in Radians. |