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

Thread: Zeros...

Threaded View

  1. #2
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: Zeros...

    Code:
    public static string stripZero(string num)
    {
        if( num.StartsWith("0.") )
            return num.Substring(1);
        if( num.StartsWith("-0.") )
            return num.Substring(2); //EDIT: A bug in this line was identified by Peter B; see below
        return num;
    }
    Last edited by BioPhysEngr; December 16th, 2011 at 02:24 AM. Reason: bug notation
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

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