public int msbIndex() {
        int index = (size() * 8) - 1;
        byteLoop:
        for (int i = 0; i < size(); i++) {
            byte b = value.get(i);
            if (b != 0) {
                for (int j = 7; j >= 0; j--) {
                    byte mask = (byte) ((1 << j) - 1);
                    if ((b & ~mask) != 0) {
                        break byteLoop;
                    }
                    index--;
                }
            }
            index -= 8;
        }
        return index;
    }
@Test
    public void testMsbIndex() {
        assertThat("Value 0 should have MSB index -1",
                   ImmutableByteSequence.copyFrom(0).msbIndex(), is(-1));
        for (int i = 0; i < 63; i++) {
            long value = (long) Math.pow(2, i);
            assertThat(format("Value %d should have MSB index %d", value, i),
                       ImmutableByteSequence.copyFrom(value).msbIndex(), is(i));
        }
    }