当前位置: 首页 > 文档资料 > 学习 Java 编程 >

rint()

优质
小牛编辑
119浏览
2023-12-01

描述 (Description)

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

语法 (Syntax)

double rint(double d)

参数 (Parameters)

这是参数的细节 -

  • d - 它接受double值作为参数。

返回值 (Return Value)

  • 此方法返回值最接近参数的整数。 作为双重归来。

例子 (Example)

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)); 
   }
}

这将产生以下结果 -

输出 (Output)

101.0
100.0
100.0