title: How is digit grouping accomplished for a calculator. For instance digit grouping numbers the same way the Windows 7 calculator does
body: <p>I'm making a calculator application for windows phone 7 and I'm struggling with digit grouping. Here's the code:</p>
  
  <p>myNumber = myNumber.Replace(",", string.Empty);</p>
  
  <pre><code>            int dot = myNumber.IndexOf("0.");
  
              strNumberWithoutDecimals = myNumber.Substring(0, (dot == -1 ? myNumber.Length : dot));
              strNumberDecimals = (dot == -1 ? "" : myNumber.Substring(dot));
  
              try
              {
                  strNumberWithoutDecimals = Convert.ToDouble(strNumberWithoutDecimals).ToString("#,##0.000000000");
              }
              catch (Exception)
              {
                  //Ignore ... for now.
              }
  
              total = strNumberWithoutDecimals + strNumberDecimals; return total;
  </code></pre>
  
  <p>The problem is when the user enters say 0.323 and the digit grouping is on, the number can't be negative. It won't work. 0.323 cannot become -0.323 and I don't know why. Any help would be highly appreciated. Thanks in advance.</p>