Hi,
What I'm trying to do is to convert a double to hex string and then back to double.
The following code does conversion double-to-hex string.
char * double2HexString(double a)
{
char *buf = new char[17]; // double is 8-byte long, so we have 2*8 + terminating \0
char *d2c;
d2c = (char *) &a;
char *n = buf;
int i;
for(i = 0; i < 8; i++)
{
sprintf(n, "%02X", *d2c++);
n += 2;
}
*(n) = '\0';
}
This seems work, however, I'm not sure how to convert the resulting string back to double. Please advise :)