Simbody  3.8

exactlyOneBitIsSet(i) provides a very fast way to determine whether an integral type has exactly one bit set.

exactlyOneBitIsSet(i) provides a very fast way to determine whether an integral type has exactly one bit set.

For unsigned and positive signed values, this is equivalent to the value being a power of two. Note that negative powers of two are not represented with a single bit set – negate it first if you want to use this routine to determine if a signed value is a negative power of two.

See also
atMostOneBitIsSet()