code: private static int interleaveBits(int odd, int even) {
          int val = 0;
          // Replaced this line with the improved code provided by Tuska
          // int n = Math.max(Integer.highestOneBit(odd), Integer.highestOneBit(even));
          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;
      }
docs: Interleave the bits from two input integer values
  
  @param odd  integer holding bit values for odd bit positions
  @param even integer holding bit values for even bit positions
  @return the integer that results from interleaving the input bits
  @todo: I'm sure there's a more elegant way of doing this !