public String toLastBitString(long value, int bits) {
        StringBuilder sb = new StringBuilder(bits);
        long lastBit = 1L << bits - 1;
        for (int i = 0; i < bits; i++) {
            if ((value & lastBit) == 0)
                sb.append('0');
            else
                sb.append('1');

            value <<= 1;
        }
        return sb.toString();
    }
@Test
    public void testToLastBitString() {
        assertEquals("1", bitUtil.toLastBitString(1L, 1));
        assertEquals("01", bitUtil.toLastBitString(1L, 2));
        assertEquals("001", bitUtil.toLastBitString(1L, 3));
        assertEquals("010", bitUtil.toLastBitString(2L, 3));
        assertEquals("011", bitUtil.toLastBitString(3L, 3));
    }