小编Ran*_*oob的帖子

Java Float"删除"逗号

我需要将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.

java int

2
推荐指数
1
解决办法
1322
查看次数

标签 统计

int ×1

java ×1