/* related posts with thumb nails */

math functions in Java:

Java provides several mathematical functions such as sqrt(), sin(), cos(), tan() and etc. These are defined in the class called Math of java.lang package. All of these functions are static functions and can be accessed without creating objects of Math class i.e. with the class name itself as shown in the following example.

Example: Math.sqrt(16)

The following table lists the different math functions available in Math class

Function

Action

sin(x)

Returns the sine of the angle x in radians

cos(x)

Returns the cosine of the angle x in radians

tan(x)

Returns the tangent of the angle x in radians

asin(y)

Returns the angle whose sine is y

acos(y)

Returns the angle whose cosine is y

atan(y)

Returns the angle whose tangent is y

atan2(x,y)

Returns the angle whose tangent is x/ y

pow(x,y)

Returns x raised to y (xy)

exp(x)

Returns e raised to x (ex)

log(x)

Returns the natural logarithm of x

sqrt(x)

Returns the square root of x

ceil(x)

Returns the smallest whole number greater than or equal to x

floor(x)

Returns the largest whole number less than or equal to x

rint(x)

Returns the truncated value of x.

round(x)

Returns the integer closest to the argument

abs(a)

Returns the absolute value of a

max(a,b)

Returns the maximum of a and b

min(a,b)

Returns the minimum of a and b

Related Topics:

0 comments:

Post a Comment