Do compact type manipulations using unsigned arithmetic
since division and modulo operations are faster in unsigned on many architectures.