@ Dave How to think about the answer to the above question . I mean How do I tackle such problems ?
On Mon, Jun 27, 2011 at 6:17 PM, Dave <[email protected]> wrote: > y = ((x & 0x55) << 1) | ((x >> 1) & 0x55). > > Note, 0x55 = 01010101 in binary. > > Dave > > On Jun 27, 7:18 am, rShetty <[email protected]> wrote: > > Given a byte, write a code to swap every two bits. [Using bit > > operators] > > > > Eg: Input: 10 01 11 01 Output: 01 10 11 10 > > -- > 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. > > -- 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.
