function withinErrorMargin (left, right) {
return Math.abs(left - right) < Number.EPSILON * Math.pow(2, 2);
}
0.1 + 0.2 === 0.3 // false
console.log(withinErrorMargin(0.1 + 0.2, 0.3)); // true
function withinErrorMargin (left, right) {
return Math.abs(left - right) < Number.EPSILON * Math.pow(2, 2);
}
0.1 + 0.2 === 0.3 // false
console.log(withinErrorMargin(0.1 + 0.2, 0.3)); // true