Re: [algogeeks] Re: Swap the LSB and MSB within themself of given no.
@dave plz run gene's code for input 0xAD...or send me some link of bitwise programing which involve simultaneous many opearation... like above... i am always confused with bitwise programing... On Sun, Nov 21, 2010 at 11:11 PM, Dave wrote: > @Coolfrog$: Don't forget the bitwise logical products. What is the bit > patterns in those hexadecimal constants? Work out the whole example > and you will see how it works. -- Dave > > On Nov 21, 8:21 am, "coolfrog$" > wrote: > > @gene > > plz explain .. what is going on... by taking example. i am unable to > run > > a test case > > 1. x=0xAD (1010 1101) > > 2. x<<1 ===>01011010 > > | > > x>>1 >01010110 > > x =0100 > > how we will get > > answer as ( 0101 1011).?? > > > > > > > > > > > > On Sun, Nov 21, 2010 at 9:59 AM, Gene wrote: > > > if the input is in unsigned char x, then > > > > > x = ((x << 1) & 0xAA) | ((x >> 1) & 0x55) > > > x = ((x << 2) & 0xCC) | ((x >> 2) & 0x33) > > > > > On Nov 20, 10:41 pm, Divesh Dixit > > > wrote: > > > > assuming all are 8bit no. > > > > input = 0x46 (0100 0110) > > > > output = 0x26 ( 0010 0110 ) > > > > input = 0x75 (0111 0101) > > > > output = 0xFC (1110 1010 ) > > > > > > Algorithm..??? > > > > > -- > > > 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. > > > > -- > > *Divesh* > > (¨`·.·´¨) Always > > `·.¸(¨`·.·´¨ ) Keep > > (¨`·.·´¨)¸.·´Smiling! > >`·.¸.·´" Life can give u 100's of reason 2cry,but u can give life > 1000's > > of reasons 2Smile"- 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. > > -- *Divesh* (¨`·.·´¨) Always `·.¸(¨`·.·´¨ ) Keep (¨`·.·´¨)¸.·´Smiling! `·.¸.·´" Life can give u 100's of reason 2cry,but u can give life 1000's of reasons 2Smile" -- 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.
Re: [algogeeks] Re: Swap the LSB and MSB within themself of given no.
x=((x>>3)&(0x11)|(a<<3)& 0x88 |(a>>1)& 0x44 | (a<<1) && 0x22) On Sun, Nov 21, 2010 at 11:11 PM, Dave wrote: > @Coolfrog$: Don't forget the bitwise logical products. What is the bit > patterns in those hexadecimal constants? Work out the whole example > and you will see how it works. -- Dave > > On Nov 21, 8:21 am, "coolfrog$" > wrote: > > @gene > > plz explain .. what is going on... by taking example. i am unable to > run > > a test case > > 1. x=0xAD (1010 1101) > > 2. x<<1 ===>01011010 > > | > > x>>1 >01010110 > > x =0100 > > how we will get > > answer as ( 0101 1011).?? > > > > > > > > > > > > On Sun, Nov 21, 2010 at 9:59 AM, Gene wrote: > > > if the input is in unsigned char x, then > > > > > x = ((x << 1) & 0xAA) | ((x >> 1) & 0x55) > > > x = ((x << 2) & 0xCC) | ((x >> 2) & 0x33) > > > > > On Nov 20, 10:41 pm, Divesh Dixit > > > wrote: > > > > assuming all are 8bit no. > > > > input = 0x46 (0100 0110) > > > > output = 0x26 ( 0010 0110 ) > > > > input = 0x75 (0111 0101) > > > > output = 0xFC (1110 1010 ) > > > > > > Algorithm..??? > > > > > -- > > > 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. > > > > -- > > *Divesh* > > (¨`·.·´¨) Always > > `·.¸(¨`·.·´¨ ) Keep > > (¨`·.·´¨)¸.·´Smiling! > >`·.¸.·´" Life can give u 100's of reason 2cry,but u can give life > 1000's > > of reasons 2Smile"- 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. > > -- DIPANKAR DUTTA M-TECH,Computer Science & Engg. E&C Dept,IIT ROORKEE Uttarakhand , India – 247667 --- website:http://people.iitr.ernet.in/shp/09535009/Website/index.html ph no-09045809987 email:dipan...@iitr.ernet.in -- 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.
Re: [algogeeks] Re: Swap the LSB and MSB within themself of given no.
@gene plz explain .. what is going on... by taking example. i am unable to run a test case 1. x=0xAD (1010 1101) 2. x<<1 ===>01011010 | x>>1 >01010110 x =0100 how we will get answer as ( 0101 1011).?? On Sun, Nov 21, 2010 at 9:59 AM, Gene wrote: > if the input is in unsigned char x, then > > x = ((x << 1) & 0xAA) | ((x >> 1) & 0x55) > x = ((x << 2) & 0xCC) | ((x >> 2) & 0x33) > > On Nov 20, 10:41 pm, Divesh Dixit > wrote: > > assuming all are 8bit no. > > input = 0x46 (0100 0110) > > output = 0x26 ( 0010 0110 ) > > input = 0x75 (0111 0101) > > output = 0xFC (1110 1010 ) > > > > Algorithm..??? > > -- > 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. > > -- *Divesh* (¨`·.·´¨) Always `·.¸(¨`·.·´¨ ) Keep (¨`·.·´¨)¸.·´Smiling! `·.¸.·´" Life can give u 100's of reason 2cry,but u can give life 1000's of reasons 2Smile" -- 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.