手册
目录
收藏844
分享
阅读878
更新时间2025-07-22
前言:
定义和用法round() 方法将数字四舍五入到最接近的整数。实例将数字四舍五入到最接近的整数:System.out.println(Math.round(0.6
round() 方法将数字四舍五入到最接近的整数。
将数字四舍五入到最接近的整数:
System.out.println(Math.round(0.60)); System.out.println(Math.round(0.40)); System.out.println(Math.round(5)); System.out.println(Math.round(5.1)); System.out.println(Math.round(-5.1)); System.out.println(Math.round(-5.9));
点击 "运行实例" 按钮查看在线实例
以下之一:
public static long round(double number) public static int round(float number)
点击 "运行实例" 按钮查看在线实例
| 参数 | 描述 |
|---|---|
| number | 必需。要四舍五入的数字。 |
| 返回: | 表示最接近数字的整数的 long 值(如果参数为 double)或 int 值(如果参数为 float)。 |
|---|---|
| Java 版本: | 任意版本。 |
相关
视频
RELATED VIDEOS
科技资讯
1
2
3
4
5
6
7
8
9
精选课程
共5课时
17.2万人学习
共49课时
77万人学习
共29课时
61.7万人学习
共25课时
39.3万人学习
共43课时
70.9万人学习
共25课时
61.6万人学习
共22课时
23万人学习
共28课时
33.9万人学习
共89课时
125万人学习