@Override
    public void decrement(final ByteBuffer byteBuffer, final int index) {
        final int cap = byteBuffer.capacity();

        if (cap >= len) {
            // Work from right to left
            for (int i = index + len - 1; i >= index; i--) {
                byte b = byteBuffer.get(i);
                if (b == (byte) 0x00) {
                    if (i == index) {
                        // Every byte is 00 so we can't decrement anymore
                        throw new IllegalArgumentException("Can't decrement without overflowing");
                    }
                    // Byte rolls drops back to FF and we need to carry over to the next one
                    byteBuffer.put(i, (byte) 0xFF);
                } else {
                    // Not going to overflow this byte so just decrement it then break out
                    // as the rest are unchanged
                    byteBuffer.put(i, (byte) (b - 1));
                    break;
                }
            }
        } else {
            throw new IllegalArgumentException(LogUtil.message(
                    "Capacity {} should be >= {}, buffer: {}",
                    cap,
                    len,
                    ByteBufferUtils.byteBufferInfo(byteBuffer)));
        }
    }
Each instance provides methods for working with unsigned longs that are written
to len bytes. The maximum numeric value of the unsigned value will be governed
by len, e.g for len == 1, the range of values are 0-255.
stroom-lmdb/src/main/java/stroom/lmdb/serde/UnsignedBytesInstances.java