JAVA_SE基礎——70.Math類

package cn.itcast.other;
/*
 Math 數學類, 主要是提供了很多的數學公式。
 
 abs(double a)  獲取絕對值
 ceil(double a)  向上取整
 floor(double a)  向下取整
 round(float a)   四捨五入
 random()   產生一個隨機數. 大於等於 0.0 且小於 1.0 的僞隨機 double 值
 
 */




public class Demo4 {

public static void main(String[] args) {
System.out.println("絕對值:"+Math.abs(-3));
System.out.println("向上取整:"+Math.ceil(3.14));
System.out.println("向下取整:"+Math.floor(-3.14)); //
System.out.println("四捨五入:"+Math.round(3.54));
System.out.println("隨機數:"+Math.random());

}

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章