okey thnks @sukran.. :) On Sat, Aug 20, 2011 at 4:20 PM, sukran dhawan <[email protected]>wrote:
> @sandeep > > number which is a power of 2 only one bit will be set. > number -1 : all the bits except the one which was set at num with be 1 > so num & num-1 will be 0 coz of bitwise and > > On Sat, Aug 20, 2011 at 4:18 PM, SANDEEP CHUGH <[email protected]>wrote: > >> @sukran explain plz >> >> On Sat, Aug 20, 2011 at 4:16 PM, sukran dhawan <[email protected]>wrote: >> >>> one more condition is required >>> >>> if(num != 0 && !( num & (num-1)) >>> >>> On Sat, Aug 20, 2011 at 4:04 PM, Sanjay Rajpal <[email protected]> wrote: >>> >>>> if(!(x & x-1)) printf("No. is power of 2"); >>>> >>>> >>>> Sanju >>>> :) >>>> >>>> >>>> >>>> On Sat, Aug 20, 2011 at 3:32 AM, Abhishek Yadav < >>>> [email protected]> wrote: >>>> >>>>> Give a one-line C expression to test whether a number is a power of 2. >>>>> >>>>> -- >>>>> 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. >>>> >>> >>> -- >>> 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. >> > > -- > 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.
