Math class contains methods for performing basic numeric operations viz mathematical operation.

Math.random() never produces zero or one. It always is between 0 and 1.

The class structure of Math is given below:

```
public class java.lang.Math extends java.lang.Object{
//member elements
public final static double E;
//E =2.7182818284590452354(double value of E)
public final static double PI;
//PI=3.14159265358979323846 (double value of PI)
//methods
public static double abs(double a);//returns the absolute value of the argument
public static double acos(double a);//returns the acos or arc cos value of the argument passed
public static double asin(double a);//returns the asin or arc sin value of the argument passed
public static double atan(double a);//returns the atan or arc tan value of the argument passed
public static double atan2(double a,double b);//returns theta after converting rectangular
//co-ordinates(a,b) to polar Double (r,theta).
public static double ceil(double a);//returns the smallest integer less than or equal to the argument.
//This is also called rounding up.
public static double cos(double a);//returns the cos value of the argument passed
public static double exp(double a);//returns the base of natural log(e) to the power argument
public static int round(double a);//returns the closed int or long
public static double floor(double a);//returns the largest integer that is less than or equal to the argument.
//This is also called rounding down.
public static double IEEEremainder(double a,double b);
public static double toDegree(double a);//returns the degree from the specified argument.
public static double toRadian(double a);//returns the radian from the specified argument.
public static double log(double a);//returns the natural log of the argument
public static double max(double a,double b);//returns the higher of the two argument passed
public static double random();//returns a generated random number
public static double rint(double a);//returns the truncated value of the argument.
public static double sin(double a);//returns the sin value of the argument passed
public static double sqrt(double a);//returns the square root of the argument
public static double tan(double a);//returns the tan value of the argument passed
public static double pow(double a,double b);//returns the argument1 to the power argument2 here
//a to the power b
public static double min(double a,double b);//returns the smaller of the two argument passed
public static int abs(int a);//returns the absolute value of the argument
public static int max(int a,int b);//returns the higher of the two argument passed
public static int min(int a,int b);//returns the smaller of the two argument passed
public static int round(float a);//returns the closed int or long
public static long abs(long a);//returns the absolute value of the argument
public static long max(long a,long b);//returns the higher of the two argument passed
public static long min(long a,long b);//returns the smaller of the two argument passed
public static long round(double a);
public static float abs(float a);//returns the absolute value of the argument
public static float max(float a,float b);//returns the higher of the two argument passed
public static float min(float a,float b);//returns the smaller of the two argument passed
}
```

All About Class Math in Java
Reviewed by Animesh Chatterjee
on
October 04, 2018
Rating:

## No comments: