Java Math中的小数转为整数方法

double d=4.22;

小数转为整数分为:

1.直接去除小数:Integer.parseInt(d);

2.4舍5入到整数:Math.round(d);

3.取小数的最小整数(向下取整):Math.floor(d);

4.取小数的最大整数(向上取整):Math.ceil(d);

猜你喜欢

转载自1015786613.iteye.com/blog/2229608