public static boolean increment ( byte [ ] value ) { for ( int i = value . length ; -- i >= 0 ; ) { byte newValue = ( byte ) ( ( value [ i ] & 0xff ) + 1 ) ; value [ i ] = newValue ; if ( newValue != 0 ) { // No carry bit, so done adding. return true ; } } // This point is reached upon overflow. return false ; }
Adds one to an unsigned integer represented as a byte array . If overflowed value in byte array is 0x00 0x00 0x00 ...