Math mathematical functions and common methods

Math is called mathematical functions, but it belongs to the type of object

The reason is called mathematical functions, because the Math object provides many operational digital methods

Math.abs (10);: absolute value

ceil / floor: rounding up or down

Math.ceil(10.01); //11
Math.ceil(-10.01);//-10

Math.floor(10.999);//10
Math.floor(-10.999);//-11

round: rounding

Math.round(10.49); //10
Math.round(-10.51);//-11

sqrt: square root

Math.sqrt(100);//10
Math.sqrt(16);//4

pow: exponentiation (N M Power)

Math.pow (2,10); // 10 10 242 a power

max / min: Get Max / Min

PI: Get pi

Math.PI; // 3.1415925653589793

random: random decimal acquisition

Math.random(); // 0.04689183

Gets a random integer between 1 and 10

Math.round (Math.random () * (mn ) + n); 
random integer between // 20-30; Math.round (Math.random () * (30-20) +20)

 

Guess you like

Origin www.cnblogs.com/xinxinxiangrong7/p/11432535.html