const EPSILON = Math.pow(2, -53); //1.1102230246251565e-16 function epsEqu(x,y) { return Math.abs(x - y) < EPSILON; } epsEqu(0.1+0.2, 0.3) //true
201702112331_《js缺陷-数值比较补救》
原文:http://www.cnblogs.com/beesky520/p/6390268.html