I appreciate all the answers from you, thank you very much.
I must stress, the program I wrote is a Win32 program, so I can not use C++, I just want to know if I can find a way to control the float value's precision using C instead of C++:
I recently wrote a programme under Win32 environment, I have a problem which I can not solve independently.
double a ;
TCHAR *k = "152.3", DigitArray[ 100 ] ;
a = strtod( k, NULL ) ; // convert a string to double.
a + = 100 ;
_gvct( a, 100, DigitArray ) ; //Convert double to string.
TextOut( hdc, 0, 0, DigitArray, NULL ) ;
The value of 'a' would be shown as 252.29999999999993, just becaue the default precision is 14 after the decimial point, I hope the value is 252.3 instead of 252.29999999999993, so I wish somebody can tell me a way to solve the above-mentioned problem.
Only C language is acceptable, any methods based on C++ is
not valid !
Thank you very much!
Last edited by ysapex; July 2nd, 2004 at 11:37 AM.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.