Quote:
Originally Posted by https://en.wikipedia.org/wiki/Logical_shift
All currently relevant C standards (ISO/IEC 9899:1999 to 2011) leave a definition gap for cases where the number of shifts is equal to or bigger than the number of bits in the operands in a way that the result is undefined.
|
This means that shifting the bits farther than available bits is not defined. Thus, the behavior can be unpredictable. You should never rely on something that is not defined by a standard (unless you yourself are able to control how it is handled; in this case you can't control it) and is why you should do it the proper way with what Bugsy suggested.
In other words, just because it works empirically for now, doesn't mean that a future update won't break it.
__________________