This behavior is undefined in C / C ++.
The standard specifically leaves this undefined, because different processors will do different things when such shifts are presented. In particular, on 32-bit Intel, I believe that only 5-bit shift values are used by the processor, and the remaining bits are simply ignored. If I remember correctly, PowerPC and 64-bit Intel use low 6 bits and ignore the rest.
A higher-level language may try to smooth this out by correcting the results to be more logically consistent, but a low-level language such as C / C ++ should be “close to metal” and will generate a single bit-shift for the <<
operator.
source share