1) 将float 或Double直接转成int 或long时,会只取整数部分,如下:
(int)(1.23)=1;
(int)(1.99)=1;
new Double(1.99).intValue()=1
2)若要四舍五入,使用Math.round().
1) 将float 或Double直接转成int 或long时,会只取整数部分,如下:
(int)(1.23)=1;
(int)(1.99)=1;
new Double(1.99).intValue()=1
2)若要四舍五入,使用Math.round().
转载于:https://www.cnblogs.com/zhongkl/archive/2011/07/22/2113925.html