Skip to content

Instantly share code, notes, and snippets.

@VorticonCmdr
Created March 16, 2022 07:52
Show Gist options
  • Save VorticonCmdr/3e2d4af64bdb1d84c415077945585b5f to your computer and use it in GitHub Desktop.
Save VorticonCmdr/3e2d4af64bdb1d84c415077945585b5f to your computer and use it in GitHub Desktop.
Hamming distance for BigInt
function hdist(a, b) {
let one = BigInt(1);
let d = 0;
let h = a ^ b;
while (h > 0) {
d ++;
h &= h - one;
}
return d;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment