An overview of the math class and its member methods
The math class contains methods for performing basic mathematical operations, such as elementary exponents, logarithms, square roots, and trigonometric functions.
Member variables:
public static final double PI
pubilc static final double E
Member Methods:
public static int abs (int a)//absolute value
public static double Ceil (double A): Rounding up
public static double floor (double a): Rounding down
public static int max (int a,int b): Maximum value
public static Double pow (double a,double b): Power of B of a
public static Double Random (): random number [0,1]
public static long round (float a): rounding
public static double sqrt (double A): positive square root
Package cn;/** * math: Classes * member variables for mathematical operations: * public static final double PI * pubilc static final double E * member Methods: * public static int abs (Int a)//Absolute value * public static double ceil (Double a): Rounding up * public static Double floor (double a): Rounding down * public static int max (int  A,INT B): Maximum Value * public static double pow ( DOUBLE A,DOUBLE B): The second power of B of a * public static double random (): random number [0,1] * public static long round ( Float a): Rounded * public static double sqrt (double a): Seek positive square root  */PUBLIC CLAss mathdemo {public static void main (String[] args) {//public static final double pisystem.out.println (Math.PI);//3.141592653589793//pubilc static final double esystem.out.println (MATH.E);//2.718281828459045//public static int abs (int  A)//Absolute System.out.println (Math.Abs ( -1));//1system.out.println (Math.Abs (1));//1//public static Double ceil (Double a): Rounding Up System.out.println (Math.ceil (0.1));//1.0system.out.println (Math.ceil (12.34 );//13.0system.out.println (Math.ceil (12.78));//13.0//public static double floor (Double a) : Rounding Down System.out.println (Math.floor (12.34));//12.0system.out.println (Math.floor (12.78));//12.0//public Static int max (int a,int b): Maximum Value System.out.println (Math.max (12, 13));//13//public static double pow (DOUBLE A,DOUBLE B): The Power System.out.println of B of A (Math.pow (2, 3)); /8.0//public statiC round (float a): Rounded System.out.println (Math.Round (4.5));//5// public static double sqrt (Double a): Seek positive square root System.out.println (MATH.SQRT (4));//2}}
This article is from the "11831428" blog, please be sure to keep this source http://11841428.blog.51cto.com/11831428/1860502
Java's math class