shifts of negative values are UB, so do the shift for the unsigned equivalent and cast to int afterwards.