
Product
Socket Now Available on Google Cloud Marketplace
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
parsegraph-fuzzyequals
Advanced tools
Compares two values, allowing for a variable amount of tolerance.
import fuzzyEquals from 'parsegraph-fuzzyequals';
let iters = 0;
let delta = 1;
const a = 1;
let isFuzzyEqual = false;
while(a !== a + delta) {
iters++;
const b = a + delta;
if (!isFuzzyEqual && fuzzyEquals(a, b)) {
console.log(`Iteration ${iters}. delta=${delta}`);
console.log(`fuzzyEquals(${a}, ${b})=${fuzzyEquals(a, b)}`);
isFuzzyEqual = true;
}
delta = delta / 2;
}
console.log(`Iteration ${iters}. delta=${delta}`);
console.log(`${a} === ${a + delta}: ${a === a + delta}`);
Output:
Iteration 21. delta=9.5367431640625e-7
fuzzyEquals(1, 1.0000009536743164)=true
Iteration 53. delta=1.1102230246251565e-16
1 === 1: true
FAQs
Compares numbers within a set tolerance
The npm package parsegraph-fuzzyequals receives a total of 0 weekly downloads. As such, parsegraph-fuzzyequals popularity was classified as not popular.
We found that parsegraph-fuzzyequals demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.
Research
Security News
Research uncovers Black Basta's plans to exploit package registries for ransomware delivery alongside evidence of similar attacks already targeting open source ecosystems.