CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Jul 2004
    Posts
    6

    A problem of setting precison

    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.

    IMPORTANT:

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured