在JavaScript中添加某些浮点数时,这些特定浮点数的输出会返回长数字

时间:2015-04-17 23:09:10

标签: javascript floating-point

I was trying to add a few decimal points initialized as variables and the output of the number was extremely long: 

var a = .1 ;
var b = .2 ;
var c = a + b ;
document.write(c) ;

c变量返回0.30000000000000004的数字,我已经搜索过高和宽,并且无法找到解释为什么有些浮点数会返回完全舍入的答案而有些不会。

0 个答案:

没有答案
相关问题