js_ Math 方法
2018-02-27 14:21
399 查看
<html>
<head>
<title>js</title>
</head>
<body>
<script>
document.write(Math.PI+'</br>'); //3.141592653589793
document.write(Math.min(1,4,2)+'</br>');// 最小数 1
document.write(Math.max(1,4,2)+'</br>'); // 最大数 4
document.write(Math.round(12.61)+'</br>'); //第一位小数四舍五入,和后面的小数没有关系 13
document.write(Math.ceil(12.11)+'</br>');//向上舍入 13
document.write(Math.floor(12.61)+'</br>'); // 向下舍入 12
document.write(Math.floor(Math.random()*100+1)+'</br>');//0~100之间的随机数
</script>
</body>
</html>
<head>
<title>js</title>
</head>
<body>
<script>
document.write(Math.PI+'</br>'); //3.141592653589793
document.write(Math.min(1,4,2)+'</br>');// 最小数 1
document.write(Math.max(1,4,2)+'</br>'); // 最大数 4
document.write(Math.round(12.61)+'</br>'); //第一位小数四舍五入,和后面的小数没有关系 13
document.write(Math.ceil(12.11)+'</br>');//向上舍入 13
document.write(Math.floor(12.61)+'</br>'); // 向下舍入 12
document.write(Math.floor(Math.random()*100+1)+'</br>');//0~100之间的随机数
</script>
</body>
</html>
相关文章推荐
- JS中的Math.pow(a,b)方法
- JS: String、Array、Number、Math 属性方法汇总
- Math.Round()方法可能与我们想象的大不一样(JS、C#)
- JS的Math方法使用
- js中单体对象(Global/Math)转码解码的方法和Date简介
- js中Math.floor和Math.ceil解释以及字符串转化为数字的方法
- js的Math常用方法
- JS基础之Math对象的属性和方法
- js中Math方法的小技巧
- js中常用的Math方法总结
- JS中常用的Math方法
- js中Math对象属性和方法详解
- JS本地面向对象Math数字的常使用方法
- Js 内Math 对象的方法
- js获取数组中最小的值的方法 Math.min.apply(),apply(),call()方法使用
- Javascript - Math 对象 - 某个数字区域之间的随机数(精确度:小数点后两位)toFixed方法原生JS实现
- JS总结篇--JS中常用的Math方法整理
- Math.random()-实现浏览器验证码点击刷新的JS方法核心
- Math.Round()方法可能与我们想象的大不一样(JS、C#)
- PHP与JS中的math.random()对应方法切换