Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

char representation of a double

Status
Not open for further replies.

senorbuckwheat

Programmer
Joined
Jul 12, 2002
Messages
17
Location
US
Hi,

I am looking for a way to convert a double to the char representation, ie. put double, which is eight bytes, to char[8];
Example:

double nDb = 12.34;
char szDb[8];

szdB would hold the character representation of nDb which might look something like:
[0] 0''
[1] 0''
[2] 0''
[3] 0''
[4] 0''
[5] 0''
[6] 51'3'
[7] 64'@'
 
double nDb = 12.34;
char szDb[sizeof(nDB)];

memcpy (szDb, &nDb, sizeof (nDb));
 
sprintf(szDb, "%f", nDb);

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top