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
@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