15 April 2012

Math Class in Java




The Math class contains all the floating-point functions that are used for geometry and
trigonometry, as well as several general-purpose methods. Math defines two double
constants: E (approximately 2.72) and PI (approximately 3.14).

Transcendental Functions

The following three methods accept a double parameter for an angle in radians and
return the result of their respective transcendental function:

Method Description:

static double sin(doublearg) Returns the sine of the angle specified by arg in radians.

static double cos(double arg)  Returns the cosine of the angle specified by arg in radians.

static double tan(double arg)  Returns the tangent of the angle specified by arg in radians.


static double asin(double arg) Returns the angle whose sine is specified by arg.
static double acos(double arg) Returns the angle whose cosine is specified by  arg.
                 
static double atan(double arg) Returns the angle whose tangent is specified by arg.
static double atan2(double x,double y)  Returns the angle whose tangent is x/y.



Exponential Functions

Math defines the following exponential methods:

Method Description
static double exp(double arg) Returns e to the arg.
static double log(double arg) Returns the natural logarithm of arg.
static double pow(double y, x) double Returns y raised to the x;
static double sqrt(double arg)
Returns the square root of arg.



Rounding Functions

The Math class defines several methods that provide various types of rounding
operations.

static int abs(int arg) Returns the absolute value of arg.
static long abs(long arg) Returns the absolute value of arg.
static float abs(float arg) Returns the absolute value of arg.
static double abs(double arg) Returns the absolute value of arg.
static double ceil(double arg) Returns the smallest whole number greater than or equal to arg.
static double floor(double arg) Returns the largest whole number less than or equal to arg.
static int max(int x, int y) Returns the maximum of x and y.
static long max(long x, y) long Returns the maximum of x and y.

static float max(float x,y)  float Returns the maximum of x and y.

static double max(double x,double y)  Returns the maximum of x and y.

static int min(int x, int y) Returns the minimum of x and y
static long min(long x, long y) Returns the minimum of x and y.
static float min(float x, float y) Returns the minimum of x and y.
static double min(double x,double y)  Returns the minimum of x and y.

static double rint(double arg) Returns the integer nearest in value to arg.
static int round(float arg) Returns arg rounded up to the nearest int.
static long round(double arg) Returns arg rounded up to the nearest long.


Miscellaneous Math Methods

In addition to the methods just shown, Math defines the following methods:
static double IEEEremainder(double dividend, double divisor)
static double random( )
static double toRadians(double angle)
static double toDegrees(double angle)

1 comments:

Naviya Nair said...

I have read your blog its very attractive and impressive. I like it your blog.

Java Online Training Java EE Online Training Java EE Online Training Java 8 online training Core Java 8 online training

Java Online Training from India Java Online Training from India Core Java Training Online Core Java Training Online Java Training InstitutesJava Training Institutes

Post a Comment

Related Posts with Thumbnails

Popular Posts

 
;