Thursday, September 17, 2009

do something-2

Continuing on do something series, here is the second problem. The following C code snippet does something and we needed to figure out what it was doing . This was actually tougher than what the professor had given in the first class.
The code goes like this

#include <stdio.h>

unsigned do_something(unsigned x,int p,int n,unsigned y)
{
return x & ~(~(~0<<n)<<(p+1-n))|
(y& ~(~0<<n))<<(p+1-n);

}



Try your hands at this.

Labels: , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home