Sorting Network Verify and Draw
Check Whether Comparator Networks Sort and Draw Them
Functions
Helpers.h File Reference

Header for useful helper functions. More...

#include "Includes.h"

Go to the source code of this file.

Functions

bool odd (const UINT)
 Parity test. More...
 
bool IsPowerOf2 (const UINT n)
 Power of 2 test. More...
 
UINT CeilLog2 (const UINT n)
 Ceiling of log base 2. More...
 

Function Documentation

◆ CeilLog2()

UINT CeilLog2 ( const UINT  n)

Compute the ceiling of log base 2. For speed, this relies on the Windows API function _BitScanReverse, which uses the corresponding native machine-code instruction to find the index of the most significant 1 in the binary representation of an unsigned integer. In retrospect this is probably overkill for this application but you have to admit that it's cool.

Parameters
nA number.
Returns
Log base 2 of the smallest power of 2 greater than or equal to n.

< Ceiling of log base 2.

Definition at line 52 of file Helpers.cpp.

◆ IsPowerOf2()

bool IsPowerOf2 ( const UINT  n)

Power of 2 test.

Parameters
nA number.
Returns
true if n is a power of 2, false otherwise.

Definition at line 40 of file Helpers.cpp.

◆ odd()

bool odd ( const UINT  n)

Parity test.

Parameters
nA number.
Returns
true if n is odd, false otherwise.

Definition at line 32 of file Helpers.cpp.