math.random()、math.floor()、math.round()、math.ceil()函数
来源:互联网 发布:nginx代理apache php 编辑:程序博客网 时间:2024/05/16 02:01
分享
1、math.random()函数
Math.random()是令系统随机选取大于等于 0.0 且小于 1.0 的伪随机 double 值,是Java语言常用代码。 例如:var a:Number=Math.random()*2+1,设置一个随机1到3的变量。
2、math.floor()函数
Math.floor(x)返回小于参数x的最大整数,即对浮点数向下取整。
例如:print("floorTest 8.5: ".. math.floor(8.5)) 结果: 8
3、math.round()函数
Math.round(x)表示将x参数进行四舍五入,x必须为数字。
例如:document.write(Math.round(0.60) ) 结果:1
4、math.ceil()函数
Math.ceil(x)返回大于或等于x,并且与之最接近的整数。
注意:如果x是正数,则把小数“入”;如果x是负数,则把小数“舍”。
总结
基础的知识使我们重要的积累,不能只追求高大上的技术,有的是有一个数的取舍和约分就会对我们的程序产生极大的影响。大家一定要对基础知识熟练掌握!
阅读全文
0 1
- math.random()、math.floor()、math.round()、math.ceil()函数总结
- math.random()、math.floor()、math.round()、math.ceil()函数
- JS:Math.random(),Math.ceil(),Math.floor()与Math.round()
- Math.random()、Math.ceil()、Math.floor()、Math.round()
- javascript Math.random(),Math.floor(),Math.ceil(),Math.round()
- Math.ceil()和Math.floor()、Math.round()
- Math.round|Math.floor|Math.ceil区别
- Math.floor,Math.round,Math.ceil
- Math.round, Math.ceil 和 Math.floor
- Math.floor()/Math.ceil()/Math.round()
- Math.ceil、Math.floor、Math.round用法
- Math.ceil() 、Math.floor() 、Math.round() 三个函数的理解
- javascript中的Math.ceil() 、Math.floor() 、Math.round() 三个函数
- Math.round ceil floor
- Math ceil()、floor()、round()、random()使用
- math.floor、math.ceil
- Math.floor,Math.ceil,Math.rint,Math.round用法详解
- Math.floor,Math.ceil,Math.rint,Math.round用法详解
- 走进Spark生态圈:环境的安装与配置
- 自动爬取网站并截图
- Linux上使用IPMITool常用的命令
- 《大话设计模式》java实现之状态模式
- 在 Azure 中备份 Linux 虚拟机
- math.random()、math.floor()、math.round()、math.ceil()函数
- 关于导数非常的好文章
- Spring Boot学习(一)
- Let’s Encrypt的免费SSL证书(续签)
- Win7配置和运行TensorFlow:Object_Detection_API步骤
- 抓包|获取移动app里的数据,什么是抓包?
- 管道符和作业控制
- Spring 定时任务之 @Scheduled cron表达式
- Ethertype