Re: [PATCH] Introduce a boolean "single_bit_set" function.

Petr Tesarik
2009-05-28T12:21:21Z

Robert P. J. Day píše v Čt 23. 04. 2009 v 13:43 -0400:
> A boolean single_bit_set() routine would simplify the numerous
> constructs of the form (((n & (n - 1)) == 0)) when testing for
> single-bitness.
>
> Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
>
> ---
>
> This is similar to the current is_power_of_2() routine defined in
> include/linux/log2.h, which is mathematically identical but,
> semantically, should be defined independently just so the code is more
> readable.
>
> I'm open to an alternative function name.

ispow2() ?

Because what it really does is to check that a value is a power of two,
doesn'it.

Regards,
Petr Tesarik

P.S. aka I want my bikeshed mathematical!