数学对象

来源:互联网 发布:js调用麦克风录音 编辑:程序博客网 时间:2024/05/28 06:07
<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
  <script>
  //获取圆周率
  //alert(Math.PI);


  //获取随机数
  //document.write(Math.random()+"<br/>");
  //获取5—12之间的随机数
  //document.write(5+Math.random()*7+"<br/>"); 
  //document.write(5+Math.random()*7+"<br/>"); 
  //document.write(5+Math.random()*7+"<br/>"); 
  //document.write(parseInt(5+Math.random()*7)+"<br/>"); 
  //document.write(parseInt(5+Math.random()*7)+"<br/>"); 
  //m-n之间的随机数
  //Math.random()*(n-m)+m


  //abs()取绝对值
  //document.write(Math.abs(-100));
  
  //ceil(数值) 大于或等于该数的最小整数(向上取整法)
  //document.write(Math.ceil(4.001)); //5
  //document.write(Math.ceil(-4.001));//5


  //floor(数值) 小于或等于该数的最大整数(向下取整法)
  //document.write(Math.floor(4.001)); //4
  //document.write(Math.floor(-4.001)); //-5
  
  //min(数值1,数值2) 返回最小值
  //document.write(Math.min(45,89)); //45


  //max(数值1,数值2) 返回最大值
  //document.write(Math.max(45,89)); //89


  //pow(数值1,数值2) 返回数值1的数值2次方
  //document.write(Math.pow(3,2)); //9


  //round(数值) 四舍五入
  //document.write(Math.round(7.80943)); //8


  //sqrt(数值) 开平方根
  //document.write(Math.sqrt(16)); //4
  </script> 
 </head>
 <body>
  
 </body>
</html>
0 0