Monday, August 13, 2012

Math Class in JAVA


MATHEMATICAL CLASS IN JAVA:
Mathematical functions such as sin, cos, sqrt, log etc are frequently used in analysis of real life problems. Java supports these basic functions through Math class defined in the java.lang package. These functions should be used as:
                Math.function_name()
Functions
Actions
abs(double a)
abs(int a)
abs(float a)
abs(long a)
Return the Absolute value of a.
acos(double a)
Return the arc cosine of the argument.
asin(double a)
Return the arc sine of the argument.
atan(double a)
Return the arc tangent of the argument.
atan2(double y, double x)
Return the theta component of the point (rtheta) in polar coordinates that corresponds to the point (xy) in Cartesian coordinates.
cbrt(double a)
Return the cube root of a.
ceil(double a)
Return the smallest (closest to negative infinity) floating-point value that is greater than or equal to the argument and is equal to a mathematical integer.
cos(double a)
Return the cosine value of a.
cosh(double a)
Return the Hyperbolic cosine value of a.
exp(double a)
Return the value ea, where e is the base of the natural logarithms.
expm1(double x)
Return the value ex - 1.
floor(double a)
Returns the largest (closest to positive infinity) floating-point value that less than or equal to the argument and is equal to a mathematical integer.
getExponent(double d)
Return the unbiased exponent of the argument
getExponent(float d)

hypot(double x,double y)
Returns sqrt(x2 +y2) without intermediate overflow or underflow
log(double a)
Returns the value ln a, the natural logarithm of a.
log10(double a)
Returns the base 10 logarithm of a.
log1p(double a)
Returns the value ln(x + 1), the natural log of x + 1.
max(double a, double b)
Returns the largest value of a & b.
max(float a, float b)

max(long a, long b)

max(int a, int b)

min(double a, double b)
Returns the smallest value of a & b.
min(float a, float b)

min(long a, long b)

min(int a, int b)

nextAfter(double start, double direction)
Returns The floating-point number adjacent to start in the direction of direction.
nextAfter(float start, double direction)

nextUp(double d)
Returns The adjacent floating-point value closer to positive infinity.
nextUp(float d)

pow(double a, double b)
Returns the value ab.
random()
Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. Returned values are chosen pseudorandomly with (approximately) uniform distribution from that range.
rint(double a)
Returns the closest floating-point value to a that is equal to a mathematical integer.
round(double a)
Returns the value of the argument rounded to the nearest long value.
round(float a)
Returns the value of the argument rounded to the nearest int value.
scalb(double d, int scaleFactor)
Returns d × 2scaleFactor
sin(double a)
Returns the trigonometric sine of an angle.
sinh(double a)
Returns the trigonometric Hyperbolic sine of an angle.
sqrt(double a)
Returns the correctly rounded positive square root of a double value.
tan(double a)
Returns the trigonometric tangent of an angle.
tanh(double a)
Returns the trigonometric Hyperbolic tangent of an angle.
toDegrees(double angrad)
Returns the measurement of the angle angrad in degrees.
toRadians(double angdeg)
Returns the measurement of the angle angdeg in radians.

No comments:

Post a Comment