Add bitsDiff function.

This commit is contained in:
Oleksii Trekhleb
2018-08-13 11:02:58 +03:00
parent 2361e6fc44
commit 3c37ba4424
4 changed files with 39 additions and 25 deletions

View File

@@ -0,0 +1,13 @@
import countSetBits from './countSetBits';
/**
* Counts the number of bits that need to be change in order
* to convert numberA to numberB.
*
* @param {number} numberA
* @param {number} numberB
* @return {number}
*/
export default function bitsDiff(numberA, numberB) {
return countSetBits(numberA ^ numberB);
}