33 int toBin(
unsigned int num,
unsigned int binLen, std::vector<bool>& numBin) {
34 numBin = std::vector<bool>(binLen);
35 for(
unsigned int i = 0; i < binLen; i++) {
38 unsigned int pos = binLen -1;
40 numBin[pos] = (num%2);
47 unsigned int binToDec(
unsigned int* numBin,
unsigned int binLen) {
49 for(
unsigned int i = 0; i< binLen; i++) {
50 res = (2*res) + numBin[i];
57 return (n && (!(n & (n - 1))));
unsigned int binLength(unsigned int num)
unsigned int fastLog2(unsigned int num)
int getPrevHighestPowerOfTwo(unsigned int n)
int getNextHighestPowerOfTwo(unsigned int n)
unsigned int binToDec(unsigned int *numBin, unsigned int binLen)
A set of functions for fast binary operations.
int toBin(unsigned int dec, unsigned int binLen, std::vector< bool > &result)
Converts a decimal number to binary.
unsigned int reversibleHash(unsigned int x)
bool isPowerOfTwo(unsigned int n)
A set of efficient functions that use binary operations to perform some small computations.