Reference http://how2j.cn/k/number-string/number-string-math/319.html
Java.lang.Math provides a number of common mathematical operations and is present in the form of static methods
Rounding, random number, radical, sub-square, π, natural constant
Package Digit; Public classTestnumber { Public Static voidMain (string[] args) {floatF1 =5.4f; floatF2 =5.5f; //5.4 Rounding that is 5System. out. println (Math.Round (F1)); //5.5 rounding that is 6System. out. println (Math.Round (F2)); //get a random floating-point number between 0-1 (less than 1)System. out. println (Math.random ()); //get a random integer between 0-10 (less than ten)System. out. println (int) (Math.random () *Ten)); //start with 9, then turn to int type System. out. println (Math.sqrt (9));
///For example, (int) math.sqrt (2) = (int) 1.414=1 //Second Party (2 of 4)System. out. println (Math.pow (2,4)); //πSystem. out. println (Math.PI); //Natural ConstantsSystem. out. println (MATH.E);
Math.Abs (); Take absolute value
Math.floor (); take up the whole
Math.ceil (); Rounding down
}}
Practice-Prime
The mathematical method of Java--unfinished