private static int interleaveBits(int odd,int even){
  int val=0;
  int max=Math.max(odd,even);
  int n=0;
  while (max > 0) {
    n++;
    max>>=1;
  }
  for (int i=0; i < n; i++) {
    int bitMask=1 << i;
    int a=(even & bitMask) > 0 ? (1 << (2 * i)) : 0;
    int b=(odd & bitMask) > 0 ? (1 << (2 * i + 1)) : 0;
    val+=a + b;
  }
  return val;
}

private static int interleaveBits ( int odd , int even ) { int val = 0 ; int max = Math . max ( odd , even ) ; int n = 0 ; while ( max > 0 ) { n ++ ; max >>= 1 ; } for ( int i = 0 ; i < n ; i ++ ) { int bitMask = 1 << i ; int a = ( even & bitMask ) > 0 ? ( 1 << ( 2 * i ) ) : 0 ; int b = ( odd & bitMask ) > 0 ? ( 1 << ( 2 * i + 1 ) ) : 0 ; val += a + b ; } return val ; }
interleave the bits from two input integer values
