Skip to content

Instantly share code, notes, and snippets.

@yphastos
Last active March 7, 2019 00:53
Show Gist options
  • Save yphastos/34e0b3cc4da1a0d48ea5d87ed115f44a to your computer and use it in GitHub Desktop.
Save yphastos/34e0b3cc4da1a0d48ea5d87ed115f44a to your computer and use it in GitHub Desktop.
different Rightmost Bit
function differentRightmostBit(n, m) {
return (n^m) & -(n^m);
}
function differentRightmostBit(n, m) {
return (n ^= m) & -n;
}
function differentRightmostBit(n, m) {
return (n ^ m) & (~(n ^ m) + 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment