DLUtils Class Reference

General utility class. More...

#include <DLUtils.h>

List of all members.

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)


Detailed Description

General utility class.

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.


Member Function Documentation

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.

Parameters:
val value to be rounded
Returns:
rounded integer value

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);
yields y = 3.1416.
Parameters:
value value to be rounded
precision round value to this precision
Returns:
rounded double vaue to the indicated precision

static void DLUtils::reverseInt ( int &  iVal  )  [static]

reverse the byte order of an integer

 [1][2][3][4] -> [4][3][2][1]

Parameters:
iVal value to reverse byte order

static void DLUtils::reverseShort ( short &  sVal  )  [static]

reverse the byte order of a short

 [1][2] -> [2][1]
Parameters:
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.

Returns:
endian type

Definition at line 105 of file DLUtils.h.

References DL_BE, and DL_LE.

Referenced by DLIOStream::DLIOStream().

static char* DLUtils::getRootName ( char *  longFile  )  [static]

static char* DLUtils::getSuffix ( char *  longFile  )  [static]


The documentation for this class was generated from the following file:

DOCLIB is being developed under contract by a collaboration between:
The Laboratory for Language and Media Processing
Unviersity of Maryland, College Park
and
Booz | Allen | Hamilton

All Rights Reserved, 2003-2007