java.lang.Math可以帮到你。 int aa = 0;
int intValue;
if (aa > 0)
intValue = (int)Math.ceil(aa); //Math.ceil(double )
else
intValue = 0;
/** @return the smallest (closest to negative infinity)
* floating-point value that is not less than the argument
* and is equal to a mathematical integer.
*/
int intValue;
if (aa > 0)
intValue = (int)Math.ceil(aa); //Math.ceil(double )
else
intValue = 0;
/** @return the smallest (closest to negative infinity)
* floating-point value that is not less than the argument
* and is equal to a mathematical integer.
*/
就是将一个double转化为一个整数,并且这个整数大于或者等于这个double数。
但是你要求非负,就要自己处理了。