> For the complete documentation index, see [llms.txt](https://timmybeeflin.gitbook.io/cracking-leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://timmybeeflin.gitbook.io/cracking-leetcode/bit/2220.-minimum-bit-flips-to-convert-number.md).

# 2220. Minimum Bit Flips to Convert Number

```java
class Solution {
    public int minBitFlips(int start, int goal) {
        int count = 0;
        while (start > 0 || goal > 0) {

            count += (start & 1) ^ (goal & 1);
            start >>= 1;
            goal >>= 1;
        }
        return count;
    }
}

/**
16 8421
111
   1010

 */
```
