Ad

Java Math functions

Java Mathematical functions are in java.lang package. You can use these functions with Math.function_name()

S.No. Method Syntax Description
sin() sin(x); Calculate sin value, x is in radian.
cos() cos(x); Calculate cos value
tan() tan(x); Calculate tan value
pow() pow(x,y); Returns the x raised to y
sqrt() sqrt(x); Returns square root of x
ceil() ceil(x); Round the decimal value up.
floor() floor(x); Round the decimal value down.
abs() abs(a); Return absolute value
max() max(a,b); Return the maximum number out of a and b.
min() min(a,b); Return the minimum number out of a and b.

Value of x and y should be in double, value of a and b may be int, long, float or double.