private static int count(int n) {
        if (n == 0) {
            return 0;
        }

        int i = 0;
        while ((n & 0x1) == 0) {
            n = n >> 1;
            i++;
            if (i > 32) {
                throw new RuntimeException(Integer.toHexString(n));
            }
        }

        return i;
    }
Counts the amount of bits needed to shift till bitmask n is at zero
@param n Bitmask to test
jme3-core/src/plugins/java/com/jme3/texture/plugins/DDSLoader.java