exactlyOneBitIsSet()
[Bit-twiddling Functions]

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

Functions

bool exactlyOneBitIsSet (unsigned char v)
bool exactlyOneBitIsSet (unsigned short v)
bool exactlyOneBitIsSet (unsigned int v)
bool exactlyOneBitIsSet (unsigned long v)
bool exactlyOneBitIsSet (unsigned long long v)
bool exactlyOneBitIsSet (signed char v)
bool exactlyOneBitIsSet (char v)
bool exactlyOneBitIsSet (short v)
bool exactlyOneBitIsSet (int v)
bool exactlyOneBitIsSet (long v)
bool exactlyOneBitIsSet (long long v)

Detailed Description

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()

Function Documentation

bool SimTK::exactlyOneBitIsSet ( long long  v  )  [inline]
bool SimTK::exactlyOneBitIsSet ( long  v  )  [inline]
bool SimTK::exactlyOneBitIsSet ( int  v  )  [inline]
bool SimTK::exactlyOneBitIsSet ( short  v  )  [inline]
bool SimTK::exactlyOneBitIsSet ( char  v  )  [inline]
bool SimTK::exactlyOneBitIsSet ( signed char  v  )  [inline]
bool SimTK::exactlyOneBitIsSet ( unsigned long long  v  )  [inline]
bool SimTK::exactlyOneBitIsSet ( unsigned long  v  )  [inline]
bool SimTK::exactlyOneBitIsSet ( unsigned int  v  )  [inline]
bool SimTK::exactlyOneBitIsSet ( unsigned short  v  )  [inline]
bool SimTK::exactlyOneBitIsSet ( unsigned char  v  )  [inline]

Generated on Wed Dec 30 11:05:08 2009 for SimTKcore by  doxygen 1.6.1