我需要将float转换为int,就好像删除了逗号一样.示例:23.2343f - > 232343
private static int removeComma(float value)
{
for (int i = 0; ; i++) {
if((value * (float)Math.pow(10, i)) % 1.0f == 0.0f)
return (int)(value * Math.pow(10, i));
}
}
Run Code Online (Sandbox Code Playgroud)
问题在于数字的四舍五入.例如,如果我传递23000.2359f它变为23000236,因为它将输入四舍五入到23000.236.