jsMath绝对值和三个取整的方法

<script type="text/javascript">
			//1.绝对值方法
			console.log(Math.abs(1));//1
			console.log(Math.abs(-1));//1
			console.log(Math.abs('-1'));//隐式转换 会把字符串型-1 转换为数字型
			
			//2.三个取整方法
			//(1)Math。floor() 向下取整 往小了取值
			console.log(Math.floor(1.1));//1
			console.log(Math.floor(1.9));//1
			//(2)Math.ceil() ceil天花板 向上取整  往最大了取值
			console.log(Math.ceil(1.1));//2
			console.log(Math.ceil(1.9));//2
			//(3)Math.round()四舍五入
			console.log(Math.round(1.1));//1
			console.log(Math.round(1.9));//2
			console.log(Math.round(-1.5));//-1
		</script>```

上一篇:mysql之数学函数


下一篇:Codeforces Round #719 (Div. 3) B.Ordinary Numbers