Java Math Library

The Java Math Library provides various Functions and Constants / Properties. These Java math functions allows 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 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 TypeJava Math PropertiesDescription
static doubleMath.EIt will return the Euler’s Number E, which is approximately equal to 2.71828
static doubleMath.PIThis Java math 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 TypeJava Math FunctionsDescription
static doubleabs(double x)It will return the Absolute value of a Double value
static floatabs(float x)This Java math function will return the Absolute value of a Float value
static intabs(int x)It will return the Absolute value of an Integer
static longabs(long x)It will return the Absolute value of a Long value
static doublecbrt(double x)It returns the Cube root of the specified expression or a double value.
static doubleceil(double x)This Java math function returns the smallest double value, which is greater than or equal to the specified expression or a double value.
static doublecopySign(double magnitude, double sign)It is to find the Absolute value of the first argument along with sign specified in the second argument
static floatcopySign(float magnitude, float sign)It is to find the Absolute value of the first argument along with sign specified in the second argument
static doublefloor(double x)This Java math function returns the largest integer value, which is less than or equal to the specified expression or a double value.
static doublegetExponent(double x)It returns the unbiased exponent used in the representation of double.
static floatgetExponent(float x)It returns the unbiased exponent used in the representation of float.
static doubleIEEEremainder(double x, double y)It will calculate the remainder of two arguments as prescribed by the IEEE 754 standards and returns the value.
static doublemax(double x, double y)This Java math function returns the Largest of two double values.
static floatmax(float x, float y)It is to return the Largest of two float values.
static intmax(int x, int y)It is to return the Largest of two int values.
static longmax(long x, long y)It is to return the Largest of two long values.
static doublemin(double x, double y)It is to return the Smallest of two double values.
static floatmin(float x, float y)It is to return the Smallest of two float values.
static intmin(int x, int y)This Java math function returns the Smallest of two int values.
static longmin(long x, long y)It is to return the Smallest of two long values.
static doublenextAfter(double start, double direction)It returns floating point value that is adjacent to the first argument in the direction of the second argument.
static floatnextAfter(float start, double direction)It returns floating point value that is adjacent to the first argument in the direction of the second argument.
static doublenextUp(double x)It returns the adjacent value of given argument in the direction of positive infinity.
static floatnextUp(float x)This Java math function returns the adjacent value of the given argument in the direction of positive infinity.
static doublepow(double x, double y)It is to return the value of the first argument raised to the Power of the second argument
static doublerandom()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 doublerint(double x)It returns the double value, which is closest to the given argument and equal to a mathematical integer
static longround(double x)It rounds the specified expression or an individual number to nearest long.
static intround(double x)Round the specified expression or an individual number to nearest int.
static doublescalb(double x, int ScaleFactor)It returns x * 2ScaleFactor rounded as if performed by a single correctly rounded floating-point multiply to a member of the double value set.
static floatscalb(float x, int ScaleFactor)This Java math function returns x * 2ScaleFactor rounded as if performed by a single correctly rounded floating-point multiply to a member of the float value set.
static doublesignum(double x)It returns the signum of the given argument.
static floatsignum(float x)It returns the signum of the given argument.
static doublesqrt(double x)This Java math function is used to find the square root of a specified expression or an individual number
static doubleulp(double x)The size of an ulp of the given double argument
static floatulp(float x)The size of an ulp of the given float argument

Java Math Logarithmic Functions

The following functions are the list of Power and logarithmic functions available in Java Math Library.

Modifier TypePower and Logarithmic FunctionsDescription
static doubleexp(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 doubleexpm1(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 doublelog(double x)Logarithmic value of a given number with base E.
static doublelog10(double x)Logarithmic value of a given number with base 10.
static doublelog1p(double x)It returns the natural algorithm of the sum of the arguments and 1.

Java Math Trigonometric Functions

The following functions are the list of Trigonometric functions available in Java Math Library.

Modifier TypeTrigonometric FunctionsDescription
static doubleacos (double x)It will return the trigonometric Arc Cosine value of a Given double value
static doubleasin(double x)This Java math function will return the trigonometric Arc Sine value of a Given double value
static doubleatan(double x)It will return the trigonometric Arc Tangent value of a Given double value
static doubleatan2(double y, double x)This math functioning java will return the angle (in radius) from the X-Axis to the specified point (y, x).
static doublecos(double x)It will return the trigonometric Cosine value of a Given double value
static doublehypot(double x, double y)It will return the sqrt(x² + y²) without intermediate overflow or underflow
static doublesin(double x)This Java math sin function will return the trigonometric Sine value of a Given double value
static doubletan(double x)It will return the trigonometric Tangent value of a Given double value

Java Math Hyperbolic Functions

The Java math Hyperbolic Functions are trigonometric functions allows to perform the following Hyperbolic functions instead of Circles. The following functions are the list of Hyperbolic functions available in Java Math Library.

Modifier TypeHybrbolic FunctionsDescription
static doublecosh(double x)It will return the trigonometric Hyperbolic Cosine value of a Given double value
static doublesinh(double x)This Java math function will return the trigonometric Hyperbolic Sine value of a Given double value
static doubletanh(double x)It will return the trigonometric Hyperbolic Tangent value of a Given double value

Java Math Angular Functions

The following functions are the list of Angular functions available in Java Math Library.

Modifier TypeJava Angular FunctionsDescription
static doubletoDegrees(double x)It will convert the specified Radians angle to equivalent angle measured in Degrees.
static doubletoRadians(double x)This Java math angular function will convert the specified Degrees angle to equivalent angle measured in Radians.