#include <DLUtils.h>
Static Public Member Functions | |
static int | roundInt (double val) |
static double | roundDouble (double value, int precision) |
static void | reverseInt (int &iVal) |
static void | reverseShort (short &sVal) |
static DLEndian | testByteOrder () |
static char * | getRootName (char *longFile) |
static char * | getSuffix (char *longFile) |
DLUtils class is a utility class to store commonly used functions. All functions in the DLUtils class are static and can be called without first creating an instance of DLUtils.
Usage:
double doubleInt = 1.999234; int myInt = DLUtils::roundInt(doubleInt);
Definition at line 29 of file DLUtils.h.
static int DLUtils::roundInt | ( | double | val | ) | [static] |
Rounds a double value to the nearest integer.
The roundInt function is useful when casting the result of a floating point operation (multiplication, division, and etc.) to an integer. The result of floating operation are OS dependent because every OS may have a different floating point precision. Depending on closeness of the result to the precision boundary, the result may get rounded up to the next higher integer value for certain OS/Compiler. If the traditional cast (int)(2/3)
is used, the result for different OSs may have be different by 1.
val | value to be rounded |
static double DLUtils::roundDouble | ( | double | value, | |
int | precision | |||
) | [static] |
Rounds the double value to the precision (number of decimal places) indicated. Example:
double x = 3.14159; double y = DLUtils::roundDouble(x,4);
y = 3.1416
. value | value to be rounded | |
precision | round value to this precision |
static void DLUtils::reverseInt | ( | int & | iVal | ) | [static] |
reverse the byte order of an integer
[1][2][3][4] -> [4][3][2][1]
iVal | value to reverse byte order |
static void DLUtils::reverseShort | ( | short & | sVal | ) | [static] |
reverse the byte order of a short
[1][2] -> [2][1]
sVal | value to reverse byte order |
static DLEndian DLUtils::testByteOrder | ( | ) | [inline, static] |
Determines the endianness (byte order) of the current system.
It declares a two-byte short
int
value 0x0001. If the first byte in memory is 0x01, the system is little endian. If the first byte in memory is 0x00, the system is big endian.
Definition at line 105 of file DLUtils.h.
Referenced by DLIOStream::DLIOStream().
static char* DLUtils::getRootName | ( | char * | longFile | ) | [static] |
static char* DLUtils::getSuffix | ( | char * | longFile | ) | [static] |