c++ - Reconstructing integers using bit mask -


i quite new bit masking , bit operations. please me understanding this. have 3 integers a, b, , c , have created new number d below operations:

int = 1; int b = 2; int c = 92;  int d = (a << 14) + (b << 11) + c; 

how reconstruct a, b , c using d?

a 0000 0000 0000 0000 0000 0000 0000 0001 b 0000 0000 0000 0000 0000 0000 0000 0010 c 0000 0000 0000 0000 0000 0000 0101 1100  a<<14 0000 0000 0000 0000 0100 0000 0000 0000 b<<11 0000 0000 0000 0000 0001 0000 0000 0000 c     0000 0000 0000 0000 0000 0000 0101 1100  d     0000 0000 0000 0000 0101 0000 0101 1100                               ^ ^      {        }                               b          c             = d>>14                   b = d>>11 & 7              c = d>>0  & 2047         way ,you should make sure b <= 7 , c <= 2047   

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -