public void writeUnsignedLongAsHex(long value) throws IOException {
        int bufferIndex = 23;
        do {
            int digit = (int)(value & 15);
            if (digit < 10) {
                buffer[bufferIndex--] = (char)(digit + '0');
            } else {
                buffer[bufferIndex--] = (char)((digit - 10) + 'a');
            }

            value >>>= 4;
        } while (value != 0);

        bufferIndex++;

        write(buffer, bufferIndex, 24-bufferIndex);
    }
@Test
    public void testWriteUnsignedLongAsHex() throws IOException {
        Assert.assertEquals("ffffffffffffffff", performWriteUnsignedLongAsHex(-1));
        Assert.assertEquals("7fffffff", performWriteUnsignedLongAsHex(Integer.MAX_VALUE));
        Assert.assertEquals("ffffffff80000000", performWriteUnsignedLongAsHex(Integer.MIN_VALUE));
        Assert.assertEquals("0", performWriteUnsignedLongAsHex(0));
        Assert.assertEquals("1", performWriteUnsignedLongAsHex(1));

        Assert.assertEquals("80000000", performWriteUnsignedLongAsHex(((long) Integer.MAX_VALUE) + 1));
        Assert.assertEquals("ffffffff7fffffff", performWriteUnsignedLongAsHex(((long) Integer.MIN_VALUE) - 1));

        Assert.assertEquals("7fffffffffffffff", performWriteUnsignedLongAsHex(Long.MAX_VALUE));
        Assert.assertEquals("8000000000000000", performWriteUnsignedLongAsHex(Long.MIN_VALUE));
    }