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++
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="noone, post: 2554260"] "first four bits" is ambiguous...and depends upon whether your system is big or little endian...and as everyone knows, little endian machines suck! but, to answer your question, shift left increases the value by a power of two and shift right decreases by a power of two....so, to extract bit fields out of a number with bits numbers 2^n n=[0..15] use bits1to3=(x>>1)&0x0f; // bits 1 2 3 4 bits12to15=(x>>12)&0x0f; // bits 12 13 14 15 to extract bit fields you should shift right then use a bit mask containing all ones. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
BITWISE SHIFT question
Top