@Rajesh: In binary, mask = 111...100000 (with 4-byte ints, this is 27 1-bits followed by 5 0-bits). The logical product of num with mask zeros out the low order 5 bits while retaining the high order 27 bits. Thus, res is num truncated to the largest multiple of 32 that does not exceed num. 56 = (1*32 + 24) goes to 1*32 = 32, 64 (=2*32 + 0) stays at 2*32 = 64, and 127 (=3*32 + 31) goes to 3*32 = 96. Dave
On Saturday, November 24, 2012 2:45:24 AM UTC-6, rajesh pandey wrote: > void dosomething(int num) > { > int mask=~(1<<5-1); > int res=num&mask; > printf("%d",res); > } > int main() > { > dosomething(56); > dosomething(64); > dosomething(127); > return 0; > } > > please explain the logic behind the output. > > Thanks, > Rajesh > --