Java 教程 Java rint() 方法

jase · 2022-05-24 23:03:30 · 热度: 12

rint() 方法返回最接近参数的整数值。

语法

该方法有以下几种语法格式:

double rint(double d)

参数

  • double 类型数据。

返回值

返回 double 类型数组,是最接近参数的整数值。

实例

实例

public class Test{ public static void main(String args[]){ double d = 100.675; double e = 100.500; double f = 100.200; System.out.println(Math.rint(d)); System.out.println(Math.rint(e)); System.out.println(Math.rint(f)); } }

编译以上程序,输出结果为:

101.0
100.0
100.0

查看更多 Java Number & Math 类 相关内容

猜你喜欢:
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册