42 static double hex2d(
const string & hexer )
47 for(
int i = 0; i< hexer.size(); i++)
50 theBits = hexDigit2dec( hexer[i] );
56 memcpy( &result, &d,
sizeof(
long long int ) );
68 static string d2hex(
const double d )
76 theChars = (
char*)(
void*)&d;
77 for(
unsigned int i = 0; i <
sizeof( double ); i++ )
82 for(
unsigned int j = 0; j < 4; j++ )
84 bits |= ((theChars[i] >> j) & mask) << j;
86 hexer = dec2hexDigit(bits)+hexer;
88 for(
unsigned int j = 4; j < 8; j++ )
90 bits |= ((theChars[i] >> j) & mask) << j-4;
92 hexer = dec2hexDigit(bits)+hexer;
106 unsigned int decDigit = (int)hexDigit - (
int)
'0' ;
108 decDigit = (int)hexDigit - (
int)
'a' + 10;
120 return (
char)( decDigit + (int)
'0');
122 return (
char)( (decDigit-10)+(
int)
'a');
static unsigned int hexDigit2dec(const char hexDigit)
static char dec2hexDigit(const unsigned int decDigit)
convert double numbers to hex strings and vice versa
static string d2hex(const double d)
static double hex2d(const string &hexer)