0.01和0.02相加得到0.03,而0.1和0.2相加得出0.30000000000000004

时间:2018-10-16 10:14:43

标签: javascript

var a=0.01;
    var b = 0.02;
    console.log(a+b);
    var c=0.1;
    var d = 0.2;
    console.log(c+d);

 var a=0.01;
    var b = 0.02;
    console.log(a+b);
    var c=0.1;
    var d = 0.2;
    console.log(c+d);
    =>0.03
    =>0.30000000000000004
  

0.01和0.02相加得到0.03,而0.1和0.2相加得到0.30000000000000004,在这种情况下javascript引擎的工作原理。

0 个答案:

没有答案