Re: [algogeeks] Re: Next Input Number

2010-11-17 Thread siddharth srivastava
On 17 November 2010 10:42, Dave dave_and_da...@juno.com wrote: @Siddharth: Try this (nnwtsnoob = next number with the same number of one bits): unsigned nnwtsnoob(unsigned x) {    return (x+(x(-x)))|(((x^(x+(x(-x2)/(x(-x))); } For the explanation/justification, see

[algogeeks] Re: Next Input Number

2010-11-16 Thread Dave
@Siddharth: Try this (nnwtsnoob = next number with the same number of one bits): unsigned nnwtsnoob(unsigned x) { return (x+(x(-x)))|(((x^(x+(x(-x2)/(x(-x))); } For the explanation/justification, see http://groups.google.com/group/programming-puzzles/msg/3a05b3c8b4042d5b. Dave On Nov