<转> js中Math.round、parseInt、Math.floor和Math.ceil小数取整总结
来源:互联网 发布:npm 淘宝镜像 instal 编辑:程序博客网 时间:2024/05/01 02:16
一、Math.round
作用:四舍五入,返回参数+0.5后,向下取整。
如:
Math.round(5.57) //返回6
Math.round(2.4) //返回2
Math.round(-1.5) //返回-1
Math.round(-5.8) //返回-6
二、parseInt
作用:解析一个字符串,并返回一个整数,这里可以简单理解成返回舍去参数的小数部分后的整数。
如:
parseInt(5.57) //返回5
parseInt(2.4) //返回2
parseInt(-1.5) //返回-1
parseInt(-5.8) //返回-5
三、Math.floor
作用:返回小于等于参数的最大整数。
如:
Math.floor(5.57) //返回5
Math.floor(2.4) //返回2
Math.floor(-1.5) //返回-2
Math.floor(-5.8) //返回-6
四、Math.ceil
作用:返回大于等于参数的最小整数
Math.ceil(5.57) //返回6
Math.ceil(2.4) //返回3
Math.ceil(-1.5) //返回-1
Math.ceil(-5.8) //返回-5
0 0
- <转> js中Math.round、parseInt、Math.floor和Math.ceil小数取整总结
- Math.ceil()和Math.floor()、Math.round()
- Math.round, Math.ceil 和 Math.floor
- js Math.ceil()、Math.floor()和Math.round()
- js的向上取整(Math.ceil)向下取整(Math.floor)四舍五入(Math.round)
- JS:Math.random(),Math.ceil(),Math.floor()与Math.round()
- math.random()、math.floor()、math.round()、math.ceil()函数总结
- Java中Math.round(),Math.floor(),Math.ceil()的理解和总结
- Math类中ceil、floor、round取整介绍
- Math类中ceil、floor、round取整介绍
- js中的Math.ceil() 、Math.floor() 、Math.round() 的意思
- Math.round ceil floor
- Math.round|Math.floor|Math.ceil区别
- Math.floor,Math.round,Math.ceil
- Math.floor()/Math.ceil()/Math.round()
- Math.ceil、Math.floor、Math.round用法
- JS中Math.ceil()和Math.floor(x)的使用
- java 中 Math.round() Math.ceil() Math.floor()区别
- 功能点字典
- nyoj 1278 Prototypes analyze(平衡二叉树)
- LIB和DLL的区别与使用
- git 冲突处理
- form表单切换action值,不同按钮 提交
- <转> js中Math.round、parseInt、Math.floor和Math.ceil小数取整总结
- response.getWriter().write()功能优于springMvc的返回
- java环境配置步骤
- 快速复制构建项目
- 洛谷 P3628 [APIO2010]特别行动队
- activeMq多个监听配置
- Fragment详解之一——概述
- 修改arm下的mac地址和ip地址
- Oracle-不删表数据,修改字段类型