All About Class Math in Java

1
161
Spread the love
  • 29
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    138
    Shares

Class Math in Java
Class Math in Java

Math class contains methods for performing basic numeric operations viz mathematical operation. The Math class is in java.lang package hence we do not require to import the same package.
Math.random() never produces zero or one. It always is between 0 and 1. Math class defines constants for the mathematical values of e and PI. Math class also defines several static methods for floating-point trigonometry, exponential and other operations.

The class structure of Math is given below:

public final 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 native double acos(double a);//returns the acos or arc cos value of the argument passed
public static native double asin(double a);//returns the asin or arc sin value of the argument passed
public static native double atan(double a);//returns the atan or arc tan value of the argument passed
public static native double atan2(double a,double b);//returns theta after converting rectangular 
//co-ordinates(a,b) to polar Double (r,theta).
public static native double ceil(double a);//returns the smallest integer less than or equal to the argument. 
//This is also called rounding up.
public static native double cos(double a);//returns the cos value of the argument passed
public static native 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 native 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 native 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 native 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 synchronized double random();//returns a generated random number
public static native double rint(double a);//returns the truncated value of the argument. 
public static native double sin(double a);//returns the sin value of the argument passed
public static native double sqrt(double a);//returns the square root of the argument
public static native double tan(double a);//returns the tan value of the argument passed
public static native 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
}
 
Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 29
  • 34
  • 28
  • 35
  •  
  •  
  •  
  • 12
  •  
  •  
    138
    Shares

1 COMMENT

  1. I’m not that much of a online reader to be honest but your
    blogs really nice, keep it up! I’ll go ahead and bookmark your website to come back later on. Many thanks

LEAVE A REPLY

Please enter your comment!
Please enter your name here