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="Skarmander, post: 2459853"] The "first 4 bits" is an ambiguous phrase, as is "bit 0, 1, 2 and 3". From which end do you wish to number them? Your first statement, variable name and comment all disagree on what you're trying to do. As far as the statement goes you apparently want bits 1, 2, 3 and 4 (numbering the least significant bit 0) in positions 0, 1, 2 and 3. If you instead want the four least significant bits, you can simply do x & 0x0f. Similarly, you are extracting bits 12-15 here. If 'x' is a 16-bit unsigned integer, those are the four most significant bits. Not quite. You may be off by one. The four least significant bits are 0-3, not 1-4, and they do not need to be shifted. S. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
BITWISE SHIFT QUESTION?
Top