// To put together a 2-bit x field in bits 4 and 5 // and a 3-bit y field in low order bits 0, 1, 2 you use code like this: long z = ( x << 3 ) | y;