fix undefined behavior

<< is only defined if the number of bits to shift is smaller than the
size of the type being shifted. Thanks to Charles Ahmed for pointing out
the bug.