CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    815

    another question about sprintf

    suppose I do that:
    dMyDouble =120.2

    sprintf(szMyString, "%.2f", dMyDouble);

    szMyString will be "120.20"

    Is there a way to get "120.2" and not by:
    sprintf(szMyString, "%.1f", dMyDouble);

    since I want up to 2 decimal digits

    Thanks

  2. #2
    Join Date
    Dec 2002
    Posts
    47
    You'll have to trim off the trailing zero programmatically.

    -rick

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