Created
January 25, 2017 13:25
-
-
Save M-ZubairAhmed/e369678731ed5cf88148da835109f5d9 to your computer and use it in GitHub Desktop.
Calculating Number of Bits changed to get to new Number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int convertBits(int initialNumber, int newNumber) { | |
return Integer.bitCount(initialNumber ^ newNumber); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment