Contains various functions for bit analysis.
|
static unsigned int | binaryToGrayCode (unsigned int nBinary) |
| Convert a number to its Gray code encoding. More...
|
|
static unsigned int | boundingPowerOfTwo (unsigned int n) |
| Returns the smallest power of 2 that is greater than or equal to n. More...
|
|
static size_t | boundingShift (size_t n) |
| Returns the fewest number of times that 1 must be shifted left to make a value greater than or equal to n. More...
|
|
static void | bufferToHex (const unsigned char *pBuffer, size_t nBufferSize, char *pHexTwiceAsLarge) |
| pHex should point to a buffer that is at 2 * nBufferSize + 1 More...
|
|
static void | bufferToHexBigEndian (const unsigned char *pBuffer, size_t nBufferSize, char *pHexTwiceAsLarge) |
| pHex should point to a buffer that is at 2 * nBufferSize + 1 More...
|
|
static void | byteToHex (unsigned char byte, char *pHex) |
| Converts a byte to two hex digits. The least significate digit will come first. the most significant digit comes next. More...
|
|
static void | byteToHexBigEndian (unsigned char byte, char *pHex) |
| Converts a byte to two hex digits. The least significate digit will come first. the most significant digit comes next. More...
|
|
static int | compareDoubles (double a, double b) |
| Returns -1 if a < b, 0 if a = b, and 1 if a > b. More...
|
|
static int | compareInts (int a, int b) |
| Returns -1 if a < b, 0 if a = b, and 1 if a > b. More...
|
|
static unsigned int | countOnes (unsigned int n) |
| Returns the number of 1's in the binary representation of n. More...
|
|
static size_t | countTrailingZeros (size_t n) |
| Returns the number of trailing zeros in the binary representation of n. For example, if n=712 (binary 1011001000), it will return 3. If n=0, it will return (size_t)-1 to represent inf. More...
|
|
static unsigned int | grayCodeToBinary (unsigned int nGrayCode) |
| Convert a number in Gray code encoding to a value. More...
|
|
static void | hexToBuffer (const char *pHex, size_t nHexSize, unsigned char *pBuffer) |
| pBuffer should be half the size of nHexSize More...
|
|
static void | hexToBufferBigEndian (const char *pHex, size_t nHexSize, unsigned char *pBuffer) |
| pBuffer should be half the size of nHexSize More...
|
|
static unsigned char | hexToByte (char lsn, char msn) |
| Converts two hexadecimal digits to a byte. lsn is least significant nybble. msn is most significant nybble. More...
|
|
static bool | isPowerOfTwo (unsigned int n) |
| Returns true if a number is a power of two. More...
|
|
static bool | isValidFloat (const char *pString, size_t len) |
| returns true iff the specified string is a valid floating point number. For example, it would return true for this string "-1.2e-14", but would return false for these: "e2", "2e", "-.", "2..3", "3-2", "2e3.5", "--1", etc. More...
|
|
static unsigned short | littleEndianToN16 (unsigned short in) |
| Convert little endian to a 16-bit native integer. More...
|
|
static short | littleEndianToN16 (short in) |
| Convert little endian to a 16-bit native integer. More...
|
|
static unsigned int | littleEndianToN32 (unsigned int in) |
| Convert little endian to a 32-bit native integer. More...
|
|
static int | littleEndianToN32 (int in) |
| Convert little endian to a 32-bit native integer. More...
|
|
static unsigned long long | littleEndianToN64 (unsigned long long in) |
| Convert little endian to a 64-bit native integer. More...
|
|
static long long | littleEndianToN64 (long long in) |
| Convert little endian to a 64-bit native integer. More...
|
|
static float | littleEndianToR32 (float in) |
| Convert little endian to a 32-bit native float. More...
|
|
static double | littleEndianToR64 (double in) |
| Convert little endian to a 64-bit native float. More...
|
|
static unsigned short | n16ToLittleEndian (unsigned short in) |
| Convert a 16-bit native integer to little endian. More...
|
|
static short | n16ToLittleEndian (short in) |
| Convert a 16-bit native integer to little endian. More...
|
|
static unsigned int | n32ToLittleEndian (unsigned int in) |
| Convert a 32-bit native integer to little endian. More...
|
|
static int | n32ToLittleEndian (int in) |
| Convert a 32-bit native integer to little endian. More...
|
|
static unsigned long long | n64ToLittleEndian (unsigned long long in) |
| Convert a 64-bit native integer to little endian. More...
|
|
static long long | n64ToLittleEndian (long long in) |
| Convert a 64-bit native integer to little endian. More...
|
|
static float | r32ToLittleEndian (float in) |
| Convert a 32-bit native float to little endian. More...
|
|
static double | r64ToLittleEndian (double in) |
| Convert a 64-bit native float to little endian. More...
|
|
static unsigned short | reverseEndian (unsigned short in) |
| Switch the endian of an unsigned integer. More...
|
|
static short | reverseEndian (short in) |
| Switch the endian of an unsigned integer. More...
|
|
static unsigned int | reverseEndian (unsigned int in) |
| Switch the endian of an unsigned integer. More...
|
|
static int | reverseEndian (int in) |
| Switch the endian of an integer. More...
|
|
static unsigned long long | reverseEndian (unsigned long long in) |
| Switch the endian of a double. More...
|
|
static long long | reverseEndian (long long in) |
| Switch the endian of a double. More...
|
|
static float | reverseEndian (float in) |
| Switch the endian of a float. More...
|
|
static double | reverseEndian (double in) |
| Switch the endian of a double. More...
|
|
static int | sign (int n) |
| Returns the sign (-1, 0, +1) of an integer. More...
|
|
static int | sign (double d) |
| Returns the sign of d. More...
|
|
static void | test () |
|