どのように0.1+0.2と0.3が等しいと判断しますか?
483 ワード
function numberClose(num1,num2){
return Math.abs(num1 - num2) < Number.EPSILON;
}
var first = 0.1 +0.2
var second = 0.3
numberClose(first,second) //true
numberClose(0.0000001,0.0000002) //false