Curriculum
Course: Java Basic
Login

Curriculum

Java Basic

Java Home

0/1

Java Introduction

0/1

Java Get Started

0/1

Java Syntax

0/1

Java Comments

0/1

Java Type Casting

0/1

Java Operators

0/1

Java Booleans

0/1

Java Switch

0/1

Java Break / Continue

0/1

Java Errors and Exception

0/1
Text lesson

Java Math Methods

All Math Methods

Below is a table containing all the methods available in the Math class.

Method  

Description

Return Type

abx(x)

This method returns the absolute value of the parameter x.

double|float|int|long

acos(x)

This method returns the arccosine of the parameter x, measured in radians.

double

addExact(x, y)

This method returns the sum of the parameters x and y.

int|long

asin(x)

This method returns the arcsine of the parameter x, measured in radians.

double

atan(x)

This method returns the arctangent of the parameter x as a numeric value ranging between -π/2 and π/2 radians.

double

atan2(y,x)

This method returns the angle theta resulting from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta).

double

cbrt(x)

This method returns the cube root of the parameter x.

double

ceil(x)

This method returns the value of x rounded up to the nearest integer.

double

copySign(x, y)

This method returns the first floating-point value, x, with the sign of the second floating-point value, y.

double|float

cos(x)

This method returns the cosine of x, where x is measured in radians.

double

cosh(x)

This method returns the hyperbolic cosine of a double value.

double

decrementExact(x)

This method returns the value of x minus 1.

int|long

exp(x)

This method returns the value of Euler’s number raised to the power of x.

double

expm1(x)

This method returns the value of Euler’s number raised to the power of x, minus 1.

double

floor(x)

This method returns the value of x rounded down to the nearest integer.

double

floorDiv(x, y)

This method returns the result of dividing x by y, rounded down to the nearest integer.

int|long

floorMod(x, y)

This method returns the remainder of the division between x and y, where the result of the division was rounded down.

int|long

getExponent(x)

This method returns the unbiased exponent used in x.

int

hypot(x, y)

This method returns the square root of the sum of the squares of x and y, without experiencing intermediate overflow or underflow.

double

IEEEremainder(x, y)

This method computes the remainder operation on x and y as defined by the IEEE 754 standard.

double

incrementExact(x)

This method returns the value of x plus 1.

int|double

log(x)

This method returns the natural logarithm (base E) of the parameter x.

double

log10(x)

This method returns the logarithm of x to the base 10.

double

log1p(x)

This method returns the natural logarithm (base E) of the sum of x and 1.

double

max(x, y)

This method returns the number with the greatest value.

double|float|int|long

min(x, y)

This method returns the number with the smallest value.

double|float|int|long

multiplyExact(x, y)

This method returns the result of multiplying x by y.

int|long

negateExact(x)

This method returns the negated value of x.

int|long

nextAfter(x, y)

This method returns the floating-point number adjacent to x in the direction of y.

double|float

nextDown(x)

This method returns the floating-point value adjacent to x in the negative direction.

double|float

nextUp(x)

This method returns the floating-point value adjacent to x in the direction of positive infinity.

double|float

pow(x, y)

This method returns the value of x raised to the power of y.

double

random()

This method returns a random number within the range of 0 to 1.

double

rint(x)

This method returns the double value that is closest to x and is equal to a mathematical integer.

double

round(x)

This method returns the value of x rounded to the nearest integer.

long|int

scalb(x, y)

This method returns the value of x multiplied by 2 raised to the power of y.

double|float

signum(x)

This method returns the sign of x.

double|float

sin(x)

This method returns the sine of x, where x is measured in radians.

double

sinh(x)

This method returns the hyperbolic sine of a double value.

double

sqrt(x)

This method returns the square root of the parameter x.

double

subtractExact(x, y)

This method returns the result of subtracting y from x.


int|long

tan(x)

This method returns the tangent of an angle.

double

tanh(x)

This method returns the hyperbolic tangent of a double value.


double

toDegrees(x)

This method converts an angle measured in radians to an approximately equivalent angle measured in degrees.

double

toIntExact(x)

This method converts a long value to an integer.

int

toRadians(x)

This method converts an angle measured in degrees to an approximately equivalent angle measured in radians.

double

ulp(x)

This method returns the size of the unit of least precision (ulp) for the parameter x.

double|float

Note All methods in the Math class are static.