Java Math Functions Table (With Return Types)
Function Syntax Return Data Type Description Example Output
Absolute Value Math.abs(x) int / double Returns absolute (positive) value of x. Math.abs(-10) 10
Power Math.pow(x, y) double Returns x^y (x raised to power y). Math.pow(2, 3) 8.0
Square Root Math.sqrt(x) double Returns square root of x. Math.sqrt(36) 6.0
Cube Root Math.cbrt(x) double Returns cube root of x. Math.cbrt(27) 3.0
Maximum Math.max(a, b) int / double Returns larger of two numbers. Math.max(5, 9) 9
Minimum Math.min(a, b) int / double Returns smaller of two numbers. Math.min(5, 9) 5
Round Math.round(x) long / int Rounds x to nearest whole number. Math.round(4.7) 5
Ceiling Math.ceil(x) double Rounds x upward to nearest integer. Math.ceil(4.1) 5.0
Floor Math.floor(x) double Rounds x downward to nearest integer. Math.floor(4.9) 4.0
Random Math.random() double Returns random number between 0.0 and 1.0. Math.random() 0.0 to 1.0
PI Constant Math.PI double Returns value of π (3.14159…) Math.PI 3.14159…
Exponential Math.exp(x) double Returns e^x (e ≈ 2.718) Math.exp(1) 2.71828…
Log (Base e) Math.log(x) double Returns natural log of x. Math.log(10) 2.3025…
Log (Base 10) Math.log10(x) double Returns log base 10 of x. Math.log10(100) 2.0
Sine Math.sin(angle) double Returns sine of angle (in radians). Math.sin(Math.PI/2) 1.0
Cosine Math.cos(angle) double Returns cosine of angle (in radians). Math.cos(0) 1.0
Tangent Math.tan(angle) double Returns tangent of angle (in radians). Math.tan(Math.PI/4) 1.0
Convert to Radians Math.toRadians(deg) double Converts degrees → radians. Math.toRadians(180) 3.14159…
Convert to Degrees Math.toDegrees(rad) double Converts radians → degrees. Math.toDegrees(Math.PI) 180.0