c++ - getting certain bits from hex value -


im trying bits 6 15 of hex value in c++. im using & 0xffc0, , when print value of bits im getting values on 1024. since 10 bits highest value can accessed 1024, correct?

i have 32 bit address tag = 31 16 index = 15 6 offset = 5 0

my code looks this

long long offset = address & 0x1f; long long index = address &0xffc0; long long tag = address & 0xffff0000; 

0xffc0 65472,

address & 0xffc0

can 65472 (more 1024). need i-th bit is

address >> & 1 

which shifts address right bits, , bit you're interested in first bit of number. value and-ing 1.


Comments

Popular posts from this blog

php - trouble displaying mysqli database results in correct order -

depending on nth recurrence of job in control M -

sql server - Cannot query correctly (MSSQL - PHP - JSON) -