相关疑难解决方法(0)

在Java中保留double的精度

public class doublePrecision {
    public static void main(String[] args) {

        double total = 0;
        total += 5.6;
        total += 5.8;
        System.out.println(total);
    }
}
Run Code Online (Sandbox Code Playgroud)

上面的代码打印:

11.399999999999
Run Code Online (Sandbox Code Playgroud)

我怎么才能打印(或能够用它)11.4?

java floating-point precision double

134
推荐指数
11
解决办法
19万
查看次数

标签 统计

double ×1

floating-point ×1

java ×1

precision ×1