- 浏览: 573424 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (423)
- windows2003 (1)
- exception (3)
- java (91)
- eclipse (14)
- java web (3)
- javaScript (11)
- 装机 (1)
- sql (34)
- outlook (1)
- html (8)
- JAVA 不同区域服务器引起的乱码解决 (2)
- strtus (3)
- http (1)
- 设计模式 (4)
- Java对存储过程的调用方法 (0)
- java-数据库操作 (0)
- jdbc (7)
- dwr (2)
- 软件版本号 (1)
- jxls (1)
- ExtJS (3)
- Ajax (1)
- git (12)
- linux (20)
- mysql (14)
- maven (16)
- easyui (1)
- 日常备注 (1)
- spring (9)
- others (1)
- windows快捷键 (1)
- 工作备注 (9)
- 工作杂项 (0)
- photoshop (1)
- 开发环境配置 (0)
- jboss (1)
- 报表 (1)
- 图表 (1)
- fckeditor (1)
- 调试bug (2)
- 口令 (1)
- css (2)
- mongodb (7)
- restful (1)
- jsp (5)
- jpa (2)
- bug (1)
- js (2)
- Json (1)
- POI (1)
- xml (2)
- webstorm (1)
- java swing (1)
- ubuntu (3)
- mongo (27)
- 自我学习 (0)
- 草稿 (0)
- 单元测试 (1)
- 数据库 (2)
- ide (1)
- 大数据 (0)
- uml (1)
- spring-boot (1)
- mybatis (3)
- oracle (2)
- jetty (1)
- 学习 (0)
- 系统调优 (1)
- tomcat (2)
- kettle (1)
- 学习资源 (1)
- 架构 (2)
- database (4)
- idea (1)
- consul (1)
- hadoop (2)
- nginx (3)
- 认证 (1)
- 加密 (1)
- connection pool (1)
- loadrunner (1)
- tps (1)
- 翻墙工具 (1)
- redis (2)
- redis jedis shardjedis (1)
- spring boot (1)
- 认证授权 (1)
- ssh (1)
- svn (2)
- 多线程 (1)
最新评论
-
abcdeudi:
不错
接口和抽象类什么时候使用才合适? -
羽翼的心动:
POI中对Word处理,读取不到书签。如果要处理书签的话,就只 ...
POI根据模板(excel表头)导出excel -
pdf1192012:
高质量文章
接口和抽象类什么时候使用才合适? -
沐忆潼:
...
POI根据模板(excel表头)导出excel -
422937561:
高质量文章
接口和抽象类什么时候使用才合适?
floor 向下取整 ceil 向上取整 round 则是4舍5入的计算,round方法,它表示“四舍五入”,算法为Math.floor(x+0.5),即将原来的数字加上0.5后再向下取整,所以,Math.round(11.5)的结果为12,Math.round(-11.5)的结果为-11。 Math.floor(1.4)=1.0 Math.round(1.4)=1 Math.ceil(1.4)=2.0 Math.floor(1.5)=1.0 Math.round(1.5)=2 Math.ceil(1.5)=2.0 Math.floor(1.6)=1.0 Math.round(1.6)=2 Math.ceil(1.6)=2.0 Math.floor(-1.4)=-2.0 Math.round(-1.4)=-1 Math.ceil(-1.4)=-1.0 Math.floor(-1.5)=-2.0 Math.round(-1.5)=-1 Math.ceil(-1.5)=-1.0 Math.floor(-1.6)=-2.0 Math.round(-1.6)=-2 Math.ceil(-1.6)=-1.0
摘自:http://blog.csdn.net/biexf/article/details/5958697
备注:不管是java还是js,若是整数除以整数,小数部分将被舍弃。如下:
1.丢弃小数部分,保留整数部分
parseInt(5/2)
2.向上取整,有小数就整数部分加1
Math.ceil(5/2)
3,四舍五入.
Math.round(5/2)
4,向下取整
Math.floor(5/2)
Math 对象的方法
FF: Firefox, N: Netscape, IE: Internet Explorer
方法 描述 FF N IE
abs(x) 返回数的绝对值 1 2 3
acos(x) 返回数的反余弦值 1 2 3
asin(x) 返回数的反正弦值 1 2 3
atan(x) 以介于 -PI/2 与 PI/2 弧度之间的数值来返回 x 的反正切值 1 2 3
atan2(y,x) 返回从 x 轴到点 (x,y) 的角度(介于 -PI/2 与 PI/2 弧度之间) 1 2 3
ceil(x) 对一个数进行上舍入。 1 2 3
cos(x) 返回数的余弦 1 2 3
exp(x) 返回 e 的指数。 1 2 3
floor(x) 对一个数进行下舍入。 1 2 3
log(x) 返回数的自然对数(底为e) 1 2 3
max(x,y) 返回 x 和 y 中的最高值 1 2 3
min(x,y) 返回 x 和 y 中的最低值 1 2 3
pow(x,y) 返回 x 的 y 次幂 1 2 3
random() 返回 0 ~ 1 之间的随机数 1 2 3
round(x) 把一个数四舍五入为最接近的整数 1 2 3
sin(x) 返回数的正弦 1 2 3
sqrt(x) 返回数的平方根 1 2 3
tan(x) 返回一个角的正切 1 2 3
toSource() 代表对象的源代码 1 4 -
valueOf() 返回一个 Math 对象的原始值
摘自:http://cooler1217.iteye.com/blog/1330043
发表评论
-
文件上传
2017-02-05 09:47 386文件上传模块 -
@ModelAttribute注解的使用
2017-01-09 23:13 506https://my.oschina.net/u/176085 ... -
数组合并和判断数组包含某个元素
2017-01-09 23:10 501http://www.iteye.com/news/28296 ... -
项目创建流程
2017-01-09 23:06 383http://lion.newtouch.com/pages/ ... -
mysql 出现很多连接 sleep 问题
2017-01-09 23:00 674http://blog.csdn.net/lin_credib ... -
spring boot 学习
2016-11-28 17:05 343http://412887952-qq-com.iteye.c ... -
jxls excel上传数据
2016-11-22 15:27 528http://jxls.sourceforge.net/ref ... -
veloctiyengine gettemplate jsonobject.fromobject
2016-11-18 10:41 0/** 53. * test User 54. ... -
HDFS客户端的权限错误:Permission denied
2016-08-09 01:55 606http://www.linuxidc.com/Linux/2 ... -
java map中的key为object
2016-08-08 11:18 503http://zhidao.baidu.com/link?ur ... -
jdbc pool
2016-07-26 14:50 379[url]C:\Users\lwx328240\Desktop ... -
java 域是指什么
2016-07-15 15:36 493http://blog.csdn.net/iaiti/arti ... -
java jdbc/ojdbc 链接oracle的三种方式
2016-07-12 14:50 554http://blog.itpub.net/22664653/ ... -
java 编译器 解释器
2016-06-28 14:45 6880) javac 编译器 用于将java源代码文件编译成字节码 ... -
linux查看cpu、内存、版本信息
2016-06-24 21:44 519http://blog.chinaunix.net/uid-2 ... -
重定向控制台System.out.println输出到文件,再重定向回控制台
2016-06-24 20:18 483http://blog.csdn.net/jason_deng ... -
java 代码点 代码单元
2016-06-24 09:38 687http://blog.csdn.net/weizhaozhe ... -
java 日期
2016-06-24 09:39 327http://kingquake21.iteye.com/bl ... -
jdbc addBatch
2016-06-23 22:08 377http://www.360sdn.com/java/2014 ... -
java中的arrayList(动态数组)与静态数组
2016-06-21 20:26 927http://www.2cto.com/kf/201206/1 ...
相关推荐
js中Math之random,round,ceil,floor的用法总结.docx
主要介绍了Java Math.round(),Math.ceil(),Math.floor()的区别详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
<SPAN xss=removed>1.Math... 2.Math.floor(num); 参数num为一个数值,函数结果为num的整数部分(返回小于等于n的最大整数)。 Math.floor(num); 参数num为一个数值,函数结果为num的整数部分(返回小于等于n的最大整数
Math.ceil(): round a number up Arguments: Any numeric value or expression Returns: The closest integer greater than or equal to x. ———————————————————————————————– Math...
Math类取整方法和random随机值方法 Math类 Math类 1 掌握常用数学函数; 2 会使用Math类中的方法解决数学问题。 double ceil( double x) //返回一个大于等于 x的最小整数值 Math.ceil(2.1) 结果为 3.0 Math.ceil(2.0...
Math.ceil(Math.random()*10); // 获取从 1 到 10 的随机整数,取 0 的概率极小。Math.round(Math.random()); // 可均衡获取 0 到 1 的随机整数。Math.floor(Math.random()*10); // 可均衡获取 0 到 9 的随机整数。...
Math方法使用: Math.ceil, Math.round, Math.floor
下面来介绍将小数值舍入为整数的几个方法:Math.ceil()、Math.floor()和Math.round()。 这三个方法分别遵循下列舍入规则: ◎Math.ceil()执行向上舍入,即它总是将数值向上舍入为最接近的整数; ◎Math.floor()执行...
Math 类中提供了三个与取整有关的方法:ceil、floor、round,这些方法的作用与它们的英 文名称的含义相对应,例如,ceil 的英文意义是天花板,该方法就表示向上取整, Math.ceil(11.3)的结果为12,Math.ceil(-11.3)的...
java加密和解密 function encrypt(str, pwd) { if(pwd == null || pwd.length ) { alert("Please enter a password with which to encrypt the message."); return null; } var prand = ""; for(var i=0; i...
2、Math.ceil():返回值:返回大于或等于x,并且与之最接近的整数(如果x是正数,则把小数“入”;如果x是负数,则把小数“舍”)。 3、Math.round():四舍五入取整。 4、Math.floor():返回值:返回小于或等于x,并且...
Math.floor(12.9999) = 12 ceil:上进 Math.ceil(12.1) = 13; round: 四舍五入 Math.round(12.5) = 13 Math.round(12.4) = 12 二、小数位数控制 保留到整数: exam = Math.round(exam); 保留一位小数: exam = ...
Java-to-JavaScript Data Conversion Part III: Core JavaScript Reference Chapter 23. Core JavaScript Reference Sample Entry arguments[ ] Arguments Arguments.callee Arguments.length ...
Math.ceil(x):向上取整 Math.floor(x):向下取整 Math.max(x,y):最大值 Math.min(x,y):最小值 Math.random(x):随机数 Math.round(x):四舍五入 获取指定范围内的随机数 var x=Math.floor(Math.random()*(max-min...
Math.ceil(); //向上取整。 Math.floor(); //向下取整。 Math.round(); //四舍五入。 Math.random(); //0.0 ~ 1.0 之间的一个伪随机数。【包含0不包含1】 //比如0.8647578968666494 Math.ceil(Math.random()*10); //...
Math.ceil(x) 对数进行上舍入 Math.floor(x) 对数进行下舍入 Math.round(x) 把数四舍五入为最接近的整数 Math.max(x,y) 返回 x 和 y 中的最高值 Math.min(x,y) 返回 x 和 y 中的最低值 Math.pow(x,y) 返回...
JDK 和 JRE 有什么区别? JDK(Java Development Kit),Java开发工具包 JRE(Java Runtime Environment),Java运行环境 JDK中包含JRE,JDK中有一个名为jre的...Math提供了三个与取整有关的方法:ceil、floor、round