Math函数

来源:互联网 发布:程序员杂志 下载 编辑:程序博客网 时间:2024/06/05 01:18

注:println()为自己编写的输出函数。
math对象
ceil(x)上舍入
floor(x)下舍入
round(x)四舍五入
random()0-1的随机数

println(Math.ceil(13.3));//14println(Math.floor(13.3));//13println(Math.round(13.3));//13

获取十个1到10之间的随机数

for (var i = 0; i < 10; i++) {                          println(Math.floor(Math.random()*10+1));}
0 0