private static byte[] binaryIncrementNeg(byte[] value, long amount) {
        long amo = amount;
        int sign = 1;
        if (amount < 0) {
            amo = -amount;
            sign = -1;
        }
        for (int i = 0; i < value.length; i++) {
            int cur = ((int) amo % 256) * sign;
            amo = (amo >> 8);
            int val = (~value[value.length - i - 1] & 0x0ff) + 1;
            int total = cur - val;
            if (total >= 0) {
                amo += sign;
            } else if (total < -256) {
                amo -= sign;
                total %= 256;
            }
            value[value.length - i - 1] = (byte) total;
            if (amo == 0) {
                return value;
            }
        }
        return value;
    }
Bytewise binary increment/deincrement of long contained in byte array on given amount.

@param value  - array of bytes containing long (length &lt;= SIZEOF_LONG)
@param amount value will be incremented on (deincremented if negative)
@return array of bytes containing incremented long (length == SIZEOF_LONG)
stroom-bytebuffer/src/main/java/stroom/bytebuffer/hbase/Bytes.java