for(i=0;i<16;i++)
printf("%d\n",(num<<i&1<<15)?
1:0);consider the above code snippet....here at each iteration num is being left shifted,and it is being ANDed with 1000000000000000 same at d time. here it is assumed that system is of 16 bit that's why loop is for 16 iterations. it's better to work wid example 23 can be written in binary as 0000000000010111,if each time,this no will be shifted then ANDed with 1000000000000000, it will result in only 0(if leftmost bit of shifted no is 0) or 1(if leftmost bit of shifted no is 1)..........which eventually will give the binary equivalent of 23 iteration 1 0000000000010111 AND 1000000000000000=0 so ternary operator gives output 0 iteration 2 0000000000101110 AND 1000000000000000=0 " " " output 0 . . . iteration 11 1011100000000000 AND 1000000000000000=1 " " " " output 1 . . . ends above outputs are nothing but the bits from left to right of binary equivalent of 23 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
