Pioneer
Loading...
Searching...
No Matches
Classes | Functions
nv Namespace Reference

Classes

struct  Equal
 
struct  hash
 
struct  hash< int >
 
struct  hash< Uint32 >
 
struct  Weld
 

Functions

Uint32 nextPowerOfTwo (Uint32 x)
 
bool isPowerOfTwo (Uint32 n)
 Return true if n is a power of two.
 

Function Documentation

◆ isPowerOfTwo()

bool nv::isPowerOfTwo ( Uint32  n)
inline

Return true if n is a power of two.

◆ nextPowerOfTwo()

Uint32 nv::nextPowerOfTwo ( Uint32  x)
inline

Return the next power of two.

See also
http://graphics.stanford.edu/~seander/bithacks.html
Warning
Behaviour for 0 is undefined.
Note
isPowerOfTwo(x) == true -> nextPowerOfTwo(x) == x
nextPowerOfTwo(x) = 2 << log2(x-1)