这是一个精度的问题,找一个四舍五入的函数才可以对,对于float到int的转换,msdn如下说得比较明白
When an object of floating type is converted to an integral type, the fractional part is truncated. No rounding takes place in the conversion process. Truncation means that a number like 1.3 is converted to 1, and –1.3 is converted to –1.