chpicker
Programmer
- Apr 10, 2001
- 1,316
I work mainly with Visual FoxPro which is a VERY high-level language. I am familiar (I use the term loosely) with the structure of C/C++, but I just can't for the life of me figure out how to program for Windows. *sigh*
In any case, I have a need to convert 64-bit doubles stored in a data file to their decimal equivalents and back. While I've had great luck using UNIONs to combine a double with an __int64 and using printf(), this only gives the illusion of conversion. Using this method, I was able to construct a data file by hand by hard-coding the numbers to convert. I can't do them by hand anymore.
I need to create two functions: one that will take a DOUBLE and return a hex string as a *char, and one that will take a *char (8 2-character bytes+null terminator, total length 17) and return the DOUBLE that it represents. Any suggestions?
Ian
In any case, I have a need to convert 64-bit doubles stored in a data file to their decimal equivalents and back. While I've had great luck using UNIONs to combine a double with an __int64 and using printf(), this only gives the illusion of conversion. Using this method, I was able to construct a data file by hand by hard-coding the numbers to convert. I can't do them by hand anymore.
I need to create two functions: one that will take a DOUBLE and return a hex string as a *char, and one that will take a *char (8 2-character bytes+null terminator, total length 17) and return the DOUBLE that it represents. Any suggestions?
Ian