Let L and B be two machines. L order its bits from LSB (Least Significant Bit) to MSB (Most Significant Bit) whil
The number>>n
and number<
number
by 2^n
. It's worth noting that the behavior of these shifts is not defined if n
is negative or is larger than the width of the datatype of number
.
According to section 6.5.7 from the C99 standard:
The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated bits are filled with zeros. If E1 has an unsigned type, the value of the result is E1 × 2^E2, reduced modulo one more than the maximum value representable in the result type. If E1 has a signed type and nonnegative value, and E1 × 2^E2 is representable in the result type, then that is the resulting value; otherwise, the behavior is undefined.
The result of E1 >> E2 is E1 right-shifted E2 bit positions. If E1 has an unsigned type or if E1 has a signed type and a nonnegative value, the value of the result is the integral part of the quotient of E1 / 2^E2. If E1 has a signed type and a negative value, the resulting value is implementation-defined.
For all the compiler cares, the bits could be stacked vertically :)