Many people often indicate in discussions about the real shift operator that the C standard explicitly states that the effect of the right shift of a negative number is determined by the implementation. I can understand the historical background of this statement, given that C compilers were used to generate code for many platforms that do not use arithmetic with two additions. However, all the new developments that I know are centered around processors that do not have inherent support for any whole arithmetic other than the two add-ons.
If the code wants to perform a half-divisioned whole division into two, and it will only be run for the current or future architecture, is there any real danger that any future compiler will interpret the right shift how to do anything else? If there is a real possibility, is there a good way to provide it without adversely affecting readability, performance, or both? Are there any other dependencies that would justify the full assumption of the operatorās behavior (for example, the code will be useless for implementations that do not support function X, and implementations are unlikely to support X if they do not use extended shift characters)?
Note. I ask under the tags C99 and C11 because I would expect the new language features to be among the things that, if supported, suggest that the platform is likely to use a right shift, which is arithmetically equivalent and would be interested in knowing any compilers C99 or C11, which implement a right-side shift in any other way.
c ++ c bit-shift c99 c11
supercat
source share