201702112331_《js缺陷-数值比较补救》

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

  

posted @ 2017-02-11 23:32  Coca-code  阅读(122)  评论(0)    收藏  举报