binary - Working with bits-output in c -


i have output of program w = 33. not know how it. have idea how solve without writing binary representation of each number?

void notchicken(int w)  {     unsigned int v1 = 0x12345678;     unsigned int v2 = 0x87654785;     unsigned int v3 = 0xffffffff;     unsigned int tmp;     tmp = (v1 >> 3) | (v2 << 3);     tmp &= v3 & ~(v3 << (w >> 1));     printf("%8x\n", tmp); } 

thanks

although not idea, lets try break down operation.

you have given w = 33

the last part -

v3 & ~(v3 << (w >> 1)) going evaluate v3 & ~(v3 << 16)

v3 << 16 0xffff0000 , ~ of 0xffff

since v3 ones 0xffff. mask off upper 16 bits of previous computation.

now (v1 >> 3) | (v2 << 3);

we care lower 16 bits.

>> 3 dividing 8 , << 3 multiplying 8.

so result of first part be

0x2468acf | 0x3b2a3c28 

keeping lower 16 bits

0x8acf | 0x3c28 

finally don't know how going or without writing bitwise representation. can last hex. f.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -