Re: [algogeeks] Re: Bitwise operator - Adobe

2010-10-05 Thread neeraj agarwal
here for the next multiple of 8 i have 3 different solutions ... 1)... nextmultiple = (n/8+1)*8 2)... nextmultiple= n+(8-n%8) 3)... suppose i have 32-bit compiler for(i=32; i1; i--) { if((pow(2,i)n==0)(pow(2,i-1)n!=0)) {

[algogeeks] Re: Bitwise operator - Adobe

2010-09-29 Thread Dave
@Arun: A multiple of 8 has three rightmost bits = 0. I first though about anding out these bits and adding 8. Code for that would be answer = (n (~7)) + 8. Alternatively, round up. That you can do by adding 8 and then zeroing out the low-order three bits. Code for that would be answer = ((n +

Re: [algogeeks] Re: Bitwise operator - Adobe

2010-09-27 Thread nishaanth
how about this n+(8-(n7)) On Sun, Sep 26, 2010 at 4:48 AM, Dave dave_and_da...@juno.com wrote: @Ashwath: Thanks for the correction. Dave On Sep 26, 1:20 am, aswath G B aswat...@gmail.com wrote: @Dave Slight change u have to do #includestdio.h main() { int a = 24;

Re: [algogeeks] Re: Bitwise operator - Adobe

2010-09-27 Thread Soundar
#includeiostream using namespace std; int main() { int n,temp,ans=1; cin n; temp=n/8; temp++; cout hi temp\n; while(temp--) { temp=temp3; } cout temp; return 0; } -- You received this message because you are subscribed to the Google

Re: [algogeeks] Re: Bitwise operator - Adobe

2010-09-26 Thread aswath G B
@Dave Slight change u have to do #includestdio.h main() { int a = 24; int b = (a | 7)+1; //This Line U have to change. not a || 7. printf(%d,b); return 0; } tats it btw it is nice one line easy soln... On Sat, Sep 25, 2010 at 10:17 PM, Dave dave_and_da...@juno.com wrote:

[algogeeks] Re: Bitwise operator - Adobe

2010-09-26 Thread Dave
@Ashwath: Thanks for the correction. Dave On Sep 26, 1:20 am, aswath G B aswat...@gmail.com wrote: @Dave  Slight change u have to do #includestdio.h main() {  int a = 24;  int b = (a | 7)+1;  //This Line U have to change. not  a || 7.  printf(%d,b);  return 0; } tats

[algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread Krunal Modi
Basically, I am starting from (ans=)0 checking if it has become greater than n, if not repeat(means, add 8) else answer is found. -- 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.

Re: [algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread rahul
Example, (a) For the number 12, the next multiple of 8 is 16. (b) For the number 16, the next multiple of 8 is 24. did u mean next multiple of 8 greater than given number(12 or 16). ? On Sat, Sep 25, 2010 at 5:28 PM, Krunal Modi krunalam...@gmail.com wrote: Basically, I am starting from

Re: [algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread Rahul Singal
let the number be x . solution = x - (x%8) + 8; -- 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

Re: [algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread Baljeet Kumar
solution = ((x3) + 1)3; On Sat, Sep 25, 2010 at 5:45 PM, Rahul Singal rahulsinga...@gmail.comwrote: let the number be x . solution = x - (x%8) + 8; -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread rajess
this wont work if x=24 i.e.multiple of 8 On Sep 25, 6:00 pm, Baljeet Kumar baljeetk...@gmail.com wrote: solution = ((x3) + 1)3; On Sat, Sep 25, 2010 at 5:45 PM, Rahul Singal rahulsinga...@gmail.comwrote: let the number be x . solution = x - (x%8) + 8; -- You received this message

[algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread Dave
answer = (x || 7) + 1; Dave On Sep 25, 6:56 am, Krunal Modi krunalam...@gmail.com wrote: Q: Write an algorithm to compute the next multiple of 8 for a given positive integer using bitwise operators. Example, (a) For the number 12, the next multiple of 8 is 16. (b) For the number 16, the

Re: [algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread Baljeet Kumar
@rajess It works for all the cases. On Sat, Sep 25, 2010 at 8:42 PM, rajess rajess1...@yahoo.com wrote: this wont work if x=24 i.e.multiple of 8 On Sep 25, 6:00 pm, Baljeet Kumar baljeetk...@gmail.com wrote: solution = ((x3) + 1)3; On Sat, Sep 25, 2010 at 5:45 PM, Rahul Singal

Re: [algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread coolfrog$
@Dave very nice one line solution.. we all are revolving around x3 concept... On Sat, Sep 25, 2010 at 10:17 PM, Dave dave_and_da...@juno.com wrote: answer = (x || 7) + 1; Dave On Sep 25, 6:56 am, Krunal Modi krunalam...@gmail.com wrote: Q: Write an algorithm to compute the next

Re: [algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread saurabh agrawal
Simple one line solution without looping and efficient : i=(i7)?(i|7)+1:i) On Sun, Sep 26, 2010 at 8:43 AM, coolfrog$ dixit.coolfrog.div...@gmail.comwrote: @Dave very nice one line solution.. we all are revolving around x3 concept... On Sat, Sep 25, 2010 at 10:17 PM, Dave

Re: [algogeeks] Re: Bitwise operator - Adobe

2010-09-25 Thread kusuma sanjeev
@Saurab: Nice solution On Sun, Sep 26, 2010 at 11:27 AM, saurabh agrawal saurabh...@gmail.comwrote: Simple one line solution without looping and efficient : i=(i7)?(i|7)+1:i) On Sun, Sep 26, 2010 at 8:43 AM, coolfrog$ dixit.coolfrog.div...@gmail.com wrote: @Dave very nice one line