Java rint() 方法

Java 教程 · 2019-02-08 12:12:00

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 教程 文章: https://codercto.com/courses/l/12.html

查看所有标签

Algorithms

Algorithms

Sanjoy Dasgupta、Christos H. Papadimitriou、Umesh Vazirani / McGraw-Hill Education / 2006-10-16 / GBP 30.99

This text, extensively class-tested over a decade at UC Berkeley and UC San Diego, explains the fundamentals of algorithms in a story line that makes the material enjoyable and easy to digest. Emphasi......一起来看看 《Algorithms》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具