Java rint() 方法
rint() 方法返回最接近參數(shù)的整數(shù)值。
語(yǔ)法
該方法有以下幾種語(yǔ)法格式:
double rint(double d)
參數(shù)
- double 原始數(shù)據(jù)類(lèi)型。
返回值
返回 double 類(lèi)型數(shù)組,是最接近參數(shù)的整數(shù)值。
實(shí)例
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)); } }
編譯以上程序,輸出結(jié)果為:
101.0 100.0 100.0
更多建議: