Definition join_bits (s : bool) m e :=
  (Z.shiftl ((if s then Zpower 2 ew else 0) + e) mw + m)%Z.

Lemma join_bits_range : forall s m e, (0 <= m < 2^mw)%Z -> (0 <= e < 2^ew)%Z -> (0 <= join_bits s m e < 2 ^ (mw + ew + 1))%Z.