Math的round方法
2024-09-08 06:41:10
代码如下,后面的注释是输出的结果
public static void main(String[] args) {
System.out.println(Math.round(0.399));//
System.out.println(Math.round(0.4));//
System.out.println(Math.round(0.41));//
System.out.println(Math.round(0.499));//
System.out.println(Math.round(0.5));//
System.out.println(Math.round(0.51));//
System.out.println(Math.round(0.6));//
System.out.println("======================");
System.out.println(Math.round(-0.6));//-1
System.out.println(Math.round(-0.51));//-1
System.out.println(Math.round(-0.5));//
System.out.println(Math.round(-0.499));//
System.out.println(Math.round(-0.41));//
System.out.println(Math.round(-0.4));//
System.out.println(Math.round(-0.399));//
}
总结,round的进位是向数轴的右方向进位的,而不是按照数的绝对值进行四舍五入的
关于Math对三角函数表示的一些知识点查看https://blog.csdn.net/River_Continent/article/details/80637952
最新文章
- 纯CSS3制作超级漂亮又实用的加载小图标
- PHPCMS 标签与示例
- NSDictionary(key与value)
- hdu 4927 java求组合数(大数)
- 使用Ant命令压缩JavaScript文件
- “DataTable”是“System.Data.DataTable”和“Microsoft.Office.Interop.Excel.DataTable”之间的不明确的引用
- 禁止Linux系统被 ping
- ASP.NET没有魔法——ASP.NET MVC 路由的匹配与处理
- 大数据学习系列之一 ----- Hadoop环境搭建(单机)
- Core Animation 文档翻译 (第五篇)
- Go语言切片
- 离线安装expect
- kali linux系统配置 避免踩坑
- django 使用 request 获取浏览器发送的参数
- 深拷贝数组 np.copy
- Gunicorn独角兽
- 使用zepto实现QQ消息左滑删除效果
- 【第二周】【作业五】Scrum 每日站会
- 洛谷 P2664 树上游戏 解题报告
- 禁止复制 + 锁右键 + 禁止全选(兼容IE Chrome等)