def encode_fvwi(val, flags, flag_size=4):
 ans = (val << flag_size)
 for i in xrange(flag_size):
  ans |= (flags & (1 << i))
 return encint(ans)

def encode_fvwi ( val , flags , flag_size = 4 ) : ans = ( val << flag_size ) for i in xrange ( flag_size ) : ans |= ( flags & ( 1 << i ) ) return encint ( ans )
encode the value val and the flag_size bits from flags as a fvwi .