(Just picking the latest message to reply to, not really quite right) > > > if (moff & 0x000000ff) > > > (void)(out[outpos++] = moff >> 0), i |= 0x01; > > > if (moff & 0x0000ff00) > > > (void)(out[outpos++] = moff >> 8), i |= 0x02; > > > if (moff & 0x00ff0000) > > > (void)(out[outpos++] = moff >> 16), i |= 0x04; > > > if (moff & 0xff000000) > > > (void)(out[outpos++] = moff >> 24), i |= 0x08; Might be overkill but: #define XXX(index) do { \ if (moff & (0xffUL << ((index) * 8))) { out[outpos++] = moff >> ((index) * 8); i |= 1 << (index); } } while (0) XXX(0); XXX(1); XXX(2); XXX(3); #undef XXX would do the trick. Pick a proper name for XXX of course. Chris