一个经典的浮点数运算0.1+0.2 == 0.30000000000000004
js在运算的时候会把10进制转化为2进制;
0.1 = 0.0001100110011001...(无限)
0.2 = 0.0011001100110011...(无限)
相加后的二进制0.0100110011001100110011001100110011001100110011001100 就等于上面的数了
一个经典的浮点数运算0.1+0.2 == 0.30000000000000004
js在运算的时候会把10进制转化为2进制;
0.1 = 0.0001100110011001...(无限)
0.2 = 0.0011001100110011...(无限)
相加后的二进制0.0100110011001100110011001100110011001100110011001100 就等于上面的数了
本文标题:javascript运算精度
本文链接:https://www.haomeiwen.com/subject/hbvadftx.html
网友评论