Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
BITWISE SHIFT QUESTION?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Eric Sosman, post: 2459917"] Kenneth Brody wrote On 04/14/06 12:58,: It does, but there are two nagging difficulties. - If `foo' has padding bits, bits that are part of its representation but not part of its value, you'll be shifting by too many places. This seems to be mostly a "theoretical" concern, as C implementations where integer types have padding bits are about as rare as snowballs in Hell. Still, the Standard permits the peculiar practice, and if such a machine is ever built Murphy's Law ensures that your code will try to run on it. - If `foo' is a signed type with a negative value, the effect of right-shifting is undefined. It may or may not be possible to shift the sign bit into a value position and then isolate it with an AND; the results simply aren't predictable. This is one of the reasons why scarred veterans (where do you think the scars came from?) recommend using unsigned types for bit-walloping. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
BITWISE SHIFT QUESTION?
Top