double a = 0.1;
double b = 0.50;
double c = 0;
double d = 0.4;
double e = 0.6;
double f = 1.3;
double g = 1.6;
//Math.ceil 表示的是大於某個小數的最小整數的double值; ceiling最高限度 天花板
double ceil1 = Math.ceil(a);
double ceil2 = Math.ceil(b);
double ceil3 = Math.ceil(c);
double ceil4 = Math.ceil(d);
double ceil5 = Math.ceil(e);
//Math.round 表示的是四捨五入,且得到long值
long round1 = Math.round(a);
long round2 = Math.round(b);
long round3 = Math.round(c);
long round4 = Math.round(d);
long round5 = Math.round(e);
//Math.floor 跟Math.ceil相反,表示的是小於某個小數的最大整數值的double類型; floor底板 最底限度
double floor1 = Math.floor(a);
double floor2 = Math.floor(b);
double floor3 = Math.floor(c);
double floor4 = Math.floor(d);
double floor5 = Math.floor(e);
double floor6 = Math.floor(f);
double floor7 = Math.floor(g);
輕鬆搞定Math.ceil,Math.round,Math.floor三者的區別
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.