Simbody  3.7

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

Functions

bool SimTK::exactlyOneBitIsSet (unsigned char v)
 
bool SimTK::exactlyOneBitIsSet (unsigned short v)
 
bool SimTK::exactlyOneBitIsSet (unsigned int v)
 
bool SimTK::exactlyOneBitIsSet (unsigned long v)
 
bool SimTK::exactlyOneBitIsSet (unsigned long long v)
 
bool SimTK::exactlyOneBitIsSet (signed char v)
 
bool SimTK::exactlyOneBitIsSet (char v)
 
bool SimTK::exactlyOneBitIsSet (short v)
 
bool SimTK::exactlyOneBitIsSet (int v)
 
bool SimTK::exactlyOneBitIsSet (long v)
 
bool SimTK::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

◆ exactlyOneBitIsSet() [1/11]

bool SimTK::exactlyOneBitIsSet ( unsigned char  v)
inline

◆ exactlyOneBitIsSet() [2/11]

bool SimTK::exactlyOneBitIsSet ( unsigned short  v)
inline

◆ exactlyOneBitIsSet() [3/11]

bool SimTK::exactlyOneBitIsSet ( unsigned int  v)
inline

◆ exactlyOneBitIsSet() [4/11]

bool SimTK::exactlyOneBitIsSet ( unsigned long  v)
inline

◆ exactlyOneBitIsSet() [5/11]

bool SimTK::exactlyOneBitIsSet ( unsigned long long  v)
inline

◆ exactlyOneBitIsSet() [6/11]

bool SimTK::exactlyOneBitIsSet ( signed char  v)
inline

◆ exactlyOneBitIsSet() [7/11]

bool SimTK::exactlyOneBitIsSet ( char  v)
inline

◆ exactlyOneBitIsSet() [8/11]

bool SimTK::exactlyOneBitIsSet ( short  v)
inline

◆ exactlyOneBitIsSet() [9/11]

bool SimTK::exactlyOneBitIsSet ( int  v)
inline

◆ exactlyOneBitIsSet() [10/11]

bool SimTK::exactlyOneBitIsSet ( long  v)
inline

◆ exactlyOneBitIsSet() [11/11]

bool SimTK::exactlyOneBitIsSet ( long long  v)
inline