@Pratik:
The first line swaps the leftmost 16 bits with the rightmost 16 bits.
The second line swaps all adjacent pairs of 8-bit quantities.
The third line swaps all adjacent pairs of 4-bit quantities.
Etc.

Dave

On Dec 20, 11:29 am, Pratik Kathalkar <dancewithpra...@gmail.com>
wrote:
> On Sun, Dec 19, 2010 at 2:36 AM, Dave <dave_and_da...@juno.com> wrote:
> > For 32-bit integers:
>
> > x = ((x >> 16) & 0X0000FFFF) | ((x & 0X0000FFFF) << 16);
> > x = ((x >>  8) & 0X00FF00FF) | ((x & 0X00FF00FF) <<  8);
> > x = ((x >>  4) & 0X0F0F0F0F) | ((x & 0X0F0F0F0F) <<  4);
> > x = ((x >>  2) & 0X33333333) | ((x & 0X33333333) <<  2);
> > x = ((x >>  1) & 0X55555555) | ((x & 0X55555555) <<  1);
>
> ----->> Can U please explain the logic of this code ?
>
>
>
>
>
>
>
> > x is now the binary reversal of its original value.
>
> > Dave
>
> > On Dec 18, 1:28 pm, Ankur Khurana <ankur.kkhur...@gmail.com> wrote:
> > > you mean reverse or make 1 to 0 or 0 to 1 ?
>
> > > On Sun, Dec 19, 2010 at 12:52 AM, bittu <shashank7andr...@gmail.com>
> > wrote:
> > > > Write an Efficient C Program to Reverse Bits of a Number
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups "Algorithm Geeks" group.
> > > > To post to this group, send email to algoge...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups­.com>
> > .
> > > > For more options, visit this group athttp://
> > groups.google.com/group/algogeeks?hl=en.- Hide quoted text -
>
> > > - Show quoted text -
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to algoge...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups­.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.
>
> --
> Pratik Kathalkar
> CoEP
> BTech IT
> 8149198343- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to