bytearray - In Java, how do you iterate over the bits of two byte arrays? -


for 2 byte arrays , b of equal length, i'd find first unset bit in byte array set in byte array b, , return zero-based index or position of bit. how can so?

for example:

a: 1111 0000 0101 b: 1111 0000 1010              ^ 

try this:

int length = a.length<b.length? a.length:b.length; (int i=0; i<length; i++) {     int x = a[i]^b[i];     if (x != 0)     {         (int j=0; true; j++)         {             if ((x&1) == 1)                 return byte.size*i+j;             x >>= 1;         }     } } return -1; 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -